[DataContract]
public class GroupDto
{
    [DataMember]
    public int id { get; set; }
    [DataMember]
    public string name{ get; set; }
    [DataMember]
    public List<UserDTO> Users { get; set; }      
}
2- Create your mappings :

Mapper.CreateMap<User, UserDto>();
Mapper.CreateMap<UserDto, User>(); // Only if you convert back from dto to entity

Mapper.CreateMap<Group, GroupDto>();
Mapper.CreateMap<GroupDto, Group>(); // Only if you convert back from dto to entity
3- that's all, because auto mapper will automatically map the List<User> to List<UserDto> (since they have same name, and there is already a mapping from user to UserDto)

4- When you want to map you call :

Mapper.Map<GroupDto>(groupEntity);
Hope that helps.

 

相关文章:

  • 2021-09-29
  • 2021-04-21
  • 2021-11-14
  • 2021-10-25
  • 2022-12-23
  • 2021-08-06
  • 2021-09-04
  • 2022-01-18
猜你喜欢
  • 2022-12-23
  • 2021-05-31
  • 2022-03-02
  • 2022-12-23
  • 2021-11-11
  • 2021-07-02
相关资源
相似解决方案