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

Managing Instanced of the OpenAccessContext class in Web Applications - Overview

This section describes the most preferable ways of working with Telerik Data Access when developing a web application. One of the most important things regarding Telerik Data Access based applications is the handling of the OpenAccessContext inside a web application. The most important thing you should take care of, is that the OpenAccessContext class implements the IDisposable interface. It is traditionally difficult to handle those cases in a web application, because of the stateless nature of the web. However, there are three highly efficient ways of dealing with this issue:

  • Using a Master Page - the MasterPage is common for all the pages in a web application. You can declare the OpenAccessContext as a protected member of the MasterPage and then access it in all the pages code-behind methods.
  • Using the HttpContext - basically, you need to create a class that is responsible for getting and setting the OpenAccessContext from/to the HttpContext.
  • Creating a New Context For Each CRUD Operation - with this approach, you execute CRUD operations by creating and disposing the context whenever that is needed.