Mapping Virtual Property Automapper

automapper-5 c# entity-framework-6

Question

When it comes to mapping models, I struggle. I so own an entity model.

public class User
{
    public string UserId { get; set;}

    public ICollection<Group> Groups {get; set;}
}

the DTO model,

public class UserInfo
{   
    public string UserId { get; set;}  

    public List<GroupInfo> Groups {get; set;}
}

Therefore, I run into issues while mapping User to UserInfo. GroupInfo lacks a configuration type. How do I start the second mapping?

UserInfo is mapped as the following:

var config = new MapperConfiguratiins(cfg=>cfg.CreateMap<User,UserInfo>()); 
var mapper = config.CreateMapper();
var userInfo = mapper.Map<UserInfo>(user);
1
0
7/17/2016 11:24:26 PM

Accepted Answer

ZZZ_tmp
1
7/17/2016 8:56:05 PM


Related Questions





Related

Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow