views:

30

answers:

1

I want to have two collections of same class items in Activerecord. How to map this?

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

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

public class Resource
{
 [BelongsTo ???
}
+1  A: 

Use the ColumnKey property, e.g.:

[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;}
}
Mauricio Scheffer
I actually ended up deriving two classes from base child object, one for each collection
George Polevoy

related questions