Adam Szabo
Adam Szabo

Reputation: 11412

How to map IList<int> with Slapper.AutoMapper

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?

Upvotes: 3

Views: 4036

Answers (1)

odelvalle
odelvalle

Reputation: 66

Check the last commit on Slapper.AutoMapper repository...

https://github.com/SlapperAutoMapper/Slapper.AutoMapper/commit/5143308bb94a4951d2db43677f253f4386d1a03c

Upvotes: 5

Related Questions