Data Access has been discontinued. Please refer to this page for more information.

Managing Instances of the OpenAccessContext Class - Overview

The topics in this section show how to manage the OpenAccessContext.

Creating a New Instance of the OpenAccessContext

Before you start using the OpenAccessContext in your application, you should initialize it. The most straightforward way to do that is to use the default constructor.

FluentModel dbContext = new FluentModel();
Dim dbContext As New FluentModel()

Disposing an OpenAccessContext

Once a new instance of the OpenAccessContext has been created, a new connection to the database is also created. The connection is closed when the OpenAccessContext is disposed. The OpenAccessContext implements the IDisposable interface, thus it provides a Dispose() method and could be used inside a using statement.

FluentModel dbContext = new FluentModel();
dbContext.Dispose();

// -or-

using ( FluentModel dbContext = new FluentModel() )
{
}
Dim dbContext As New FluentModel()
dbContext.Dispose()
' -Or-
Using dbContext As New FluentModel()
End Using

In this section