Adapter pattern in the .NET BCL
The adapter pattern (aka wrapper) translates one interface for a class into a compatible interface expected by the client. This allows objects to work together, which normally wouldn't because of incompatible interfaces.
Note
This is achieved by providing its cooperating interface to clients while using the original interface to invoke the core functionality provided by the object.
The amount of code necessary to do this is most often small. The adapter is also responsible for transforming data into appropriate forms expected by the library that implements the actual logic. The adapter can be a class adapter or an object adapter. The SQLDataAdapter
class in .NET Framework represents a set of data commands (select
, update
, and delete
) and a database connection that is used to fill the DataSet
(in the case of select), or update the data source:
private static RetrieveRows( string connectionString,string queryString) { using...