我想在Activerecord中有两个相同类项的集合。 如何映射?
class Project
{
[HasMany]
IList<Resource> Resources { get; set; }
[HasMany]
IList<Resource> DepartmentResources { get; set; }
}
public class Resource
{
[BelongsTo ???
}
答案 0 :(得分:1)
使用ColumnKey属性,例如:
[HasMany(ColumnKey="res")]
IList<Resource> Resources { get; set; }
[HasMany(ColumnKey="deptres")]
IList<Resource> DepartmentResources { get; set; }
...
public class Resource {
[BelongsTo("res")]
Project Project {get;set;}
[BelongsTo("deptres")]
Project DeptProject {get;set;}
}