Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/329.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# Fluent Nhibernate-当子对象引用父对象而不使用列表时,映射父对象中的子对象_C#_Nhibernate_Fluent Nhibernate_Nhibernate Mapping - Fatal编程技术网

C# Fluent Nhibernate-当子对象引用父对象而不使用列表时,映射父对象中的子对象

C# Fluent Nhibernate-当子对象引用父对象而不使用列表时,映射父对象中的子对象,c#,nhibernate,fluent-nhibernate,nhibernate-mapping,C#,Nhibernate,Fluent Nhibernate,Nhibernate Mapping,我在数据库中有一个子对象,如下所示: CREATE TABLE Child ( ChildId uniqueidentifier not null, ParentId uniqueidentifier not null ) 然后我有一个这样的父母 CREATE TABLE Parent ( ParentId uniqueidentifier not null ) 现在的问题是,在我的家长班上,我 public virtual Child Child { get; set; } 如果可能的

我在数据库中有一个子对象,如下所示:

CREATE TABLE Child
(
ChildId  uniqueidentifier not null,
ParentId uniqueidentifier not null
)
然后我有一个这样的父母

CREATE TABLE Parent
(
ParentId uniqueidentifier not null
)
现在的问题是,在我的家长班上,我

public virtual Child Child { get; set; }
如果可能的话,我不想使用列表。我知道我可以使用hasmany来创建一个列表,然后在Parent.Child属性中从列表中选择前1个

我试过references、hasone、referencesany,但似乎无法获得正确的映射。有人有什么想法吗


谢谢,

我将这种类型的关系建模为一对多,其中多个方面被限制为n个元素(在本例中,n=1)。我将many-side建模为父级上的私有集合,并通过属性限制元素的数量。请参阅。

我必须使用一个列表,然后子属性只获取列表中的第一个。这不是一个好主意,但很管用