NHibernate 与中间表的映射
我是 NHibernate 的新手,在映射方面遇到了一些问题。
假设我有一张桌子:
People
PersonID
PersonName
PersonAge
然后我有另一张桌子
ParentRelaitions
RelationID
Parent (This is a PersonID)
Child (This is also a PersonID)
我真正想从中得到的是这样一个对象
public class Person
{
string name;
int age;
IList<Person> Children; //This is a list of all the persons children
}
我将如何设置它?我相当迷失,似乎找不到任何相关的例子。
谢谢
I am new to NHibernate and am running into some issues with mapping.
Lets say I have a table:
People
PersonID
PersonName
PersonAge
Then I have another table
ParentRelaitions
RelationID
Parent (This is a PersonID)
Child (This is also a PersonID)
What I really want to get out of this is an object like this
public class Person
{
string name;
int age;
IList<Person> Children; //This is a list of all the persons children
}
How would I go about setting this up? I am fairly lost and can't seem to find any relevant examples.
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
这应该可以帮助您开始:
This should get you started:
我不明白。父母和孩子之间是什么关系? 1:N 还是 M:N?如果是1:N则研究NHibernate关系 多对一,如果 M:N 则研究多对多。
I do not understand. What is the relationship between Parent and child? 1:N or M:N? If 1:N then study NHibernate relation many-to-one, if M:N then study many-to-many.
您的示例有点模糊,但您应该考虑使用关联类。
Your example is a bit vague, but you should look into using an Association Class.