0
我對錶函數和角色有多對多的關係,並且我有關聯表RolesFunctions。 在RolesFunctions中我有行ID(IdFunctions和IdRoles都是它的主鍵)。 問題是當我用functionDTO映射函數和角色與rolesDTO與AutoMapper我有這個錯誤「AutoMapper.dll中發生類型'System.StackOverflowException'的未處理的異常請確保您沒有無限循環或無限遞歸「。如何用automapper映射多對多
我的映射:
CreateMap<Function, FunctionTDTO>().ReverseMap();
CreateMap<Roles, RolesDTO>().ReverseMap();
如何automapper地圖多對多的關係?
功能CLASSE
public class Functions
{
public Functions()
{
this.Roles = new HashSet<Roles>();
}
public int Id { get; set; }
public string Description { get; set; }
public virtual ICollection<Roles> Roles { get; set; }
}
功能DTO
public class FunctionsDTO
{
public int Id { get; set; }
public string Description { get; set; }
public virtual ICollection<RolesDTO> Roles { get; set; }
}
角色CLASSE
public class Roles
{
public Roles()
{
this.Functions = new HashSet<Functions>();
}
public int Id { get; set; }
public string Libelle { get; set; }
public virtual ICollection<Functions> Functions { get; set; }
}
RoleDTO CLASSE
public class RolesDTO
{
public int Id { get; set; }
public string Libelle { get; set; }
public virtual ICollection<FunctionsDTO> Functions { get; set; }
}
向我們展示classes Function,FunctionDTO,Roles and RolesDTO – MacakM