Search code examples
c#dapper

Can dapper indicate if there is a field name mismatch?


class MyClass =
{ int Idx; }

sql = "SELECT ID FROM MYTABLE"

If I use this sql and class with dapper Idx won't be populated and there will be no errors.

If a field name of the query does not match the field name of the class dapper does not indicate any errors, it silently finishes the call (of course without populating Idx).

Is there a setting on dapper to get an error in this case?


Solution

  • As a workaround you can change the query something like: $"Select {nameof(MyClass.Idx)} from MyTable".