Appendix B. Creating a .NET Managed Data Provider


Chapter 3 DESCRIBED how to use database providers and demonstrated how to create a new one. A prerequisite for creating a database provider is the existence of a .NET managed data provider that provides an implementation for the interfaces that need to be returned for the virtual methods defined in the abstract Database base class. For example, the SqlDatabase class derives from the Database class and must return a class that implements the IDataReader for the virtual ExecuteReader method. It accomplishes this by using the SqlCommand and SqlDataReader classes that are provided by the .NET managed data provider for Microsoft SQL Server.

Listings 3-4 and 3-5 (in Chapter 3 ) provided examples for some of the code that needs to be written to create a new database provider that retrieves and stores data in an XML file. Part of the reason I picked this as an example was to demonstrate that you aren't without any options if a .NET managed data provider does not yet exist for the data source you need to use. It is possible to create a .NET managed data provider so that a database provider can be created to use it.

To create a .NET managed data provider that will support the needs of the Data Access Application Block, you need to develop seven classes that implement specific interfaces. These interfaces are IDataParameter, IDataParameterCollection, IDataReader, IDbCommand, IDbConnection /ICloneable, IDbDataAdapter, and IDbTransaction. This appendix shows how to create a .NET managed data provider for XML files by creating a class that implements each of these interfaces.




Fenster Effective Use of Microsoft Enterprise Library(c) Building Blocks for Creating Enterprise Applications and Services 2006
Effective Use of Microsoft Enterprise Library: Building Blocks for Creating Enterprise Applications and Services
ISBN: 0321334213
EAN: 2147483647
Year: 2004
Pages: 103
Authors: Len Fenster

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net