Reputation: 724
I have some problem with mapping models . So I have a entity model
public class User
{
public string UserId { get; set;}
public ICollection<Group> Groups {get; set;}
}
and DTO model
public class UserInfo
{
public string UserId { get; set;}
public List<GroupInfo> Groups {get; set;}
}
So I have problem when mapping User to UserInfo Missing configuration type for GroupInfo . How intialize second mapping ?
User is mapped to UserInfo as the following:
var config = new MapperConfiguratiins(cfg=>cfg.CreateMap<User,UserInfo>());
var mapper = config.CreateMapper();
var userInfo = mapper.Map<UserInfo>(user);
Upvotes: 0
Views: 3896
Reputation: 1616
Try this for your MapperConfiguration
:
var config = new MapperConfiguration(cfg =>
{
cfg.CreateMap<Group, GroupInfo>();
cfg.CreateMap<User, UserInfo>();
});
Upvotes: 1