如何使用Castle ActiveRecord建模以下内容?
我有两个课程,即客户和任务。
我想重用第三个类,注意,存储在每个Customer和Task类的Collection中。
public class Note
{
public int ID { get; set; }
public string Subject { get; set; }
public string Body { get; set; }
}
public class Customer
{
public int ID { get; set; }
public IList<Note> Notes { get; set; }
}
public class Task
{
public int ID { get; set; }
public IList<Note> Notes { get; set; }
}
然后,我希望能够将Notes集合传递到Customer或Task类的相关ASP.Net页面中的Gridview,Listview或Repeater。
答案 0 :(得分:1)
我认为你需要的是实现一个类型层次结构。你可以阅读它here。
答案 1 :(得分:0)
我们确定了以下模式:
[ActiveRecord]
public class Note
{
[PrimaryKey]
public int ID { get; set; }
[Property]
public string Subject { get; set; }
[Property]
public string Body { get; set; }
[BelongsTo]
public Customer Customer { get; set; }
[BelongsTo]
public Customer Task{ get; set; }
}
[ActiveRecord]
public class Customer
{
[PrimaryKey]
public int ID { get; set; }
[HasMany]
public IList<Note> Notes { get; set; }
}
[ActiveRecord]
public class Task
{
[PrimaryKey]
public int ID { get; set; }
[HasMany]
public IList<Note> Notes { get; set; }
}