C# 自动映射链接器表

C# 自动映射链接器表,c#,automapper,C#,Automapper,我试图映射通过链接器表连接的两个实体 OrganizationVM=Organization-|---|-Address 一对多多多对一 我的目标是从地址实体获取具有状态属性的组织视图模型。 字符串状态=OrganizationVM.state 有人知道我怎么做吗 谢谢 你能展示你的源类(组织、地址链接器和地址)和目标类(OrganizationViewModel)吗?@matendie你可以编辑你的问题,而不是试图把这些东西放在评论中。谢谢我刚刚做了…:)@matendie,组织和Addre

我试图映射通过链接器表连接的两个实体

OrganizationVM=Organization-|---|-Address
一对多多多对一

我的目标是从地址实体获取具有状态属性的组织视图模型。

字符串状态=OrganizationVM.state

有人知道我怎么做吗

谢谢



你能展示你的源类(组织、地址链接器和地址)和目标类(OrganizationViewModel)吗?@matendie你可以编辑你的问题,而不是试图把这些东西放在评论中。谢谢我刚刚做了…:)@matendie,组织和AddressLinker类之间以及AddressLinker和Address类之间没有关系。在此方案中不能使用AutoMapper。链接器同时持有作为连接(关系)的地址和组织的ID。这么多对多通过链接器表不可能映射到AutoMapper?
public class OrganizationVM : BaseViewModel 
{ 
    [Display(Name = "Parent ID")]
    [Required]
    public int? ParentID { get; set; }
    public string ParentInternalName { get; set; } 
    public string State { get; set; }
    public string StateAbr { get; set; }
    public string City { get; set; }
}

public class AddressLinker 
{ 
    public int ID {get; set;}
    public int OrganizationID { get; set; }
    public int AddressID { get; set; } 
}

public class Address 
{ 
    public int ID {get; set;}
    public string State { get; set; }
    public string Code { get; set; }
    public string City { get; set; }
}

public class Organization
{  
    public int ID {get; set;}
    public int? ParentID { get; set; }
    public string ParentInternalName { get; set; } 
    public bool StructuralNode { get; set; } 
    public string InternalName { get; set; } 
    public string ExternalShortName { get; set; } 
    public string ExternalFullName { get; set; } 
    public string State { get; set; }
    public string Code { get; set; }
    public string City { get; set; }
}