其他几个类持有的同一类的模型集合
如何使用 Castle ActiveRecord 对以下内容进行建模?
我有两个类,客户和任务。
我想重用第三个类 Note,它存储在每个 Customer 和 Task 类的集合中。
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。
How do I model the following using Castle ActiveRecord?
I have two classes, Customer and Task.
I would like to reuse a third class, Note, stored in a Collection in each of the Customer and Task classes.
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; }
}
I would then like to be able to pass the Notes collection to a Gridview, Listview or Repeater in the relevant ASP.Net page for the Customer or Task classes.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我认为你需要的是实现类型层次结构。您可以在此处阅读相关内容。
I think what you need is to implement a type hierarchy. You can read about it here.
我们确定了以下模式:
We settled on the following pattern: