-
Notifications
You must be signed in to change notification settings - Fork 3
What's supported
Setup of any Dapper method, listed below. Verification of any Dapper method, listed below. No need to setup a Dapper call (no data will be returned from the call, but it will be executed) All the power, and familiar syntax of Moq.
-
Execute
&ExecuteAsync
-
Query<T>
&QueryAsync<T>
-
QuerySingle<T>
&QuerySingleAsync<T>
-
QuerySingleOrDefault<T>
&QuerySingleOrDefaultAsync<T>
-
QueryFirst<T>
&QueryFirstAsync<T>
-
QueryFirstOrDefault<T>
&QueryFirstOrDefaultAsync<T>
-
ExecuteScalar
andExecuteScalarAsync
(from version 1.9.0)- typed versions of these methods (e.g.
ExecuteScalar<T>
) are not supported currently, see issue #19
- typed versions of these methods (e.g.
- SQL (case insensitive, ignores empty lines & leading/trailing white-space)
- Parameters
- Transaction
- CommandType
- CommandTimeout
E.g.
conn.Query<Car>("select * from vehicles where id = @id", new { id = 1});
conn.Query<Truck>("select * from vehicles where id = @id", new { id = 1});
Set Settings.Default.ResetDapperCachePerCommand
to true
to solve this. Note this is not thread safe, there is no other known solution to this circumstance at present. This setting can be defined statically via Settings.Default
or supplied via an instance of the Settings
provided to the MockDbConnection
The buffered
argument to non-Async Query
et.al. will not be set correctly when called via the library.
Currently there is no known way to maintain this value when executing the command. There is an issue to resolve this if possible.
Like with the buffered
argument, the following arguments aren't currently set correctly, therefore cannot be accurately asserted
map
types
splitOn
Issues exist to resolve these where possible, but currently there is no solution except to not expect/verify these values, i.e use It.IsAny<>()
for now.
There is a Dapper method for ExecuteScalar
but it isn't currently supported. There is an issue to support this, and other remaining Dapper methods.