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

Disposing the OpenAccessContext

The OpenAccessContext.Dispose method releases the resources used by the context. This method closes the connection if it was opened by Telerik Data Access. After the Dispose method is called, operations that require an open connection, such as executing a query will cause an exception.

using (FluentModel dbContext = new FluentModel())
{
}
Using dbContext As New FluentModel()
End Using

Additionally, the context exposes the DisposeDatabase method. This method is used to dispose the underlying database object from one context, but applies to all the contexts using it. The "reason" argument is used for logging (if the logging is enabled).

FluentModel dbContext = new FluentModel();
dbContext.DisposeDatabase("ApplicationShutDown");
Dim dbContext As New FluentModel()
dbContext.DisposeDatabase("ApplicationShutDown")