城堡Activerecord。两个同一类的集合

时间:2010-03-22 11:58:47

标签: castle-activerecord

我想在Activerecord中有两个相同类项的集合。 如何映射?

class Project
{
 [HasMany]
 IList<Resource> Resources { get; set; }

 [HasMany]
 IList<Resource> DepartmentResources { get; set; }
}

public class Resource
{
 [BelongsTo ???
}

1 个答案:

答案 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;}
}