George Polevoy
George Polevoy

Reputation: 7681

Castle Activerecord. Two collections of the same class

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 ???
}

Upvotes: 0

Views: 133

Answers (1)

Mauricio Scheffer
Mauricio Scheffer

Reputation: 99730

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

Upvotes: 1

Related Questions