How to map IList with Slapper.AutoMapper

c# dapper

Question

I'm trying to use Slapper.AutoMapper alongside Dapper to accomplish something like this: How do I write one to many query in Dapper.Net?.

My POCO is like this:

public class MyEntity
{
    public string Name { get; set; }
    public string Description { get; set; }
    public int Level { get; set; }
    public IList<int> Types { get; set; }
}

And my DB rows returned are like this:

enter image description here

So one entity can have many Types. This is how I map the stuff:

dynamic test = conn.Query<dynamic>(sql); Slapper.AutoMapper.Configuration.AddIdentifier(typeof(MyEntity), "Name");
var testContact = Slapper.AutoMapper.MapDynamic<MyEntity>(test);

However in all my result objects the Types property is null. How can I map all the Type values in to the IList Types?

Accepted Answer



Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Is this KB legal? Yes, learn why
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Is this KB legal? Yes, learn why