Posts Tagged ‘dapper’

Scope_Identity doesn’t return an Int in sqlserver but a Decimal

Dec 5th, 2011

This is an old item.  Scope_Identity in Sqlserver doesn’t return an Int but a Decimal.  So in Dapper the call is

                var id = conn.Query<Decimal>(...

Honour those who should and here.

Exception: Dapper throws Value cannot be null. Parameter name: con

Jul 18th, 2011

If you are using Dapper and try to select data into an object and don’t have a default constructor the exception

Value cannot be null.
Parameter name: con

might be thrown.

The stack is:

[ArgumentNullException: Value cannot be null.
Parameter name: con]
   System.Reflection.Emit.DynamicILGenerator.Emit(OpCode opcode, ConstructorInfo con) +9566558
   Dapper.SqlMapper.GetClassDeserializer(IDataReader reader, Int32 startBound, Int32 length, Boolean returnNullIfFirstMissing) in C:\pathtomyproject\SqlMapper.cs:1177
   Dapper.SqlMapper.GetDeserializer(IDataReader reader, Int32 startBound, Int32 length, Boolean returnNullIfFirstMissing) in C:\pathtomyproject\SqlMapper.cs:674
   Dapper.<QueryInternal>d__4`1.MoveNext() in C:\pathtomyproject\SqlMapper.cs:397
   System.Collections.Generic.List`1..ctor(IEnumerable`1 collection) +327
   System.Linq.Enumerable.ToList(IEnumerable`1 source) +58
   Dapper.SqlMapper.Query(IDbConnection cnn, String sql, Object param, IDbTransaction transaction, Boolean buffered, Nullable`1 commandTimeout, Nullable`1 commandType) in C:\pathtomyproject\SqlMapper.cs:348