FluentNhibernate HasMany与组件 [英] FluentNhibernate HasMany with component
问题描述
HasMany< ClassA>(ot => ot.AList)
。 Table(XPTO)
.KeyColumn(IDXPTO)
.Component(m =>
{
m.Map(a => aX,X );
m.Map(x => xY,Y);
})
.Cascade.AllDeleteOrphan();
我得到一个错误,提示引用了一个未映射的class classA,但是我不需要映射它。我在互联网上看到了类似映射的其他例子,他们没有这个问题...
如果我只为ID创建一个classMap classMap,那么它的工作,但数据模型将有一个不必要的表classA只有id,因为属性X和Y将被映射到表XPTO ...
好的,未映射类的错误不是由于hasmany,而是我在那里有一个一对一地引用ClassA的其他属性。所以我有一对一的关系到classA和一对多,第一个是导致错误。
我解决了一对一的问题,然后工作。
i have this mapping:
HasMany<ClassA>(ot => ot.AList)
.Table("XPTO")
.KeyColumn("IDXPTO")
.Component(m =>
{
m.Map(a=> a.X, "X");
m.Map(x=> x.Y, "Y");
})
.Cascade.AllDeleteOrphan();
i get an error saying that "refers to an unmapped class ClassA", but i shouldn't need to map it. i saw other examples in the internet with similar mappings and they don't have this problem...
if i create a classMap for class A only with ID, then its works, but the data model will have 1 unecessary table for classA with only the id, because property X and Y will be mapped on the table XPTO...
ok, the error of unmapped class was not due to the hasmany, but to other property i had there that refered to ClassA on a one-to-one. So i had a one-to-one relatioshi to classA and a one-to-many, the 1st one was causing the error. I solved that one to one then it worked.
这篇关于FluentNhibernate HasMany与组件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!