Export (0) Print
Expand All

Overview of the Provider Independent Model 

ADO.NET 2.0 introduces new base classes in the System.Data.Common namespace. The base classes are abstract, which means that they can't be directly instantiated. They include DbConnection, DbCommand, and DbDataAdapter and are shared by the .NET Framework data providers, such as System.Data.SqlClient and System.Data.OleDb. The addition of base classes simplifies adding functionality to the .NET Framework data providers without having to create new interfaces.

In addition, the introduction of abstract base classes with ADO.NET 2.0 enables a developer to write generic data access code that does not depend on a specific data provider.

The Factory Design Pattern

The programming model for writing provider-independent code is based on the use of the "factory" design pattern, which uses a single API to access databases across multiple providers. This pattern is aptly named, as it calls for the use of a specialized object solely to create other objects, much like a real-world factory. For a more detailed description of the factory design pattern, see "Writing Generic Data Access Code in ASP.NET 2.0 and ADO.NET 2.0" on MSDN.

In ADO.NET 2.0, the DbProviderFactories class provides static (or Shared in Visual Basic) methods for creating a DbProviderFactory instance. The instance then returns a correct strongly typed object based on provider information and the connection string supplied at run time. See Working with Factories for code samples demonstrating the use of the factory design pattern in ADO.NET.

See Also

Community Additions

ADD
Show:
© 2014 Microsoft