You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Dapper creates a case sensitive dictionary when returning the query result and you make a simple casing mistake on a column name the slapper will not map.
To fix change line 134 in Slapper.AutoMapper.cs with: var dictionary = dynamicListOfProperties .Select(dynamicItem => new Dictionary<string, object>(dynamicItem as IDictionary<string, object>,StringComparer.OrdinalIgnoreCase)).ToList();
To reproduce the issue run this simple example:
public class book
{
[AutoMapper.Id]
public string name { get; set; }
}
static class Program
{
[STAThread]
static void Main()
{
var cnn = DBUtils.CreateConnection("Data Source=localhost;Integrated Security=true;Initial Catalog=local;", DbServType.SqlServer);
cnn.Open();
var qres= cnn.Query<dynamic>(
@"select 'xxxx' as 'Name'
UNION
select 'asdas' as 'Name'");
var ent = AutoMapper.MapDynamic<book>(qres,false);
}
}
The text was updated successfully, but these errors were encountered:
I wish SlapperAutoMapper had better support for controlling case sensitivity and conversions of one name to another. I am using a PostgreSQL database that has column names like my_column (the standard naming convention for PostgreSQL databases) and I'm trying to map them to a C# property called MyColumn. The only way I've found to do this is by aliasing every column that contains an underscore within the SQL statement. Tedious, for sure.
I also have similar problems mapping PostgreSQL enumeration values (my_enum_value) to a C# enumeration (EnumValues.MyEnumValue).
Dapper creates a case sensitive dictionary when returning the query result and you make a simple casing mistake on a column name the slapper will not map.
To fix change line 134 in Slapper.AutoMapper.cs with:
var dictionary = dynamicListOfProperties .Select(dynamicItem => new Dictionary<string, object>(dynamicItem as IDictionary<string, object>,StringComparer.OrdinalIgnoreCase)).ToList();
To reproduce the issue run this simple example:
The text was updated successfully, but these errors were encountered: