A light abstraction around Dapper and Dapper.Contrib that also maintains the behavior IDbConnection. This library facilitates a loosely coupled design and unit testing.
The IDataAccessor interface encapsulates Dapper extension methods. Just provide the connection to the DataAccessor.
IDataAccessor dataAccessor = new DataAccessor(new SqlConnection(connectionString));
Execute Dapper queries and commands as you would normally.
var person = await dataAccessor.QueryAsync<Person>(sql, new {Id});
Note: The dataAccessor should be disposed appropriately.
IDataReaderAccessor encapsulates IDataReader extension methods. Use GetDataReaderAccessor() to convert the IDataReader object to an IDataReaderAccessor.
var dataReader = await dataAccessor.ExecuteReaderAsync(sql);
var dataReaderAccessor = dataAccessor.GetDataReaderAccessor(dataReader);
var result = dataReaderAccessor.Parse<Person>();
IDataAccessor includes the Dapper.Contrib extension methods
dataAccessor.Insert(new Person { Name = "John Doe" });
IDataAccessor implements IDbConnection, so you can access things like the ConnectionTimeout, ConnectionString, and ConnectionState etc.
If you need access to the actual connection object, use GetUnderlyingConnection():
IDbConnection connection = dataAccessor.GetUnderlyingConnection();