流利的nHibernate Join就是插入到连接的表中 [英] Fluent nHibernate Join is doing insert into joined table
问题描述
我试图使用连接从另一个表中获取一个属性,但没有映射。我的问题是,当我创建我的映射实体的新实例,并保存它时,我得到一个关于尝试插入到我的未映射表(它试图插入一个非空列的空值)的错误。我想使用.ReadOnly()会停止nhibernate尝试插入到我的未映射表,但似乎并没有工作。
我的映射如下所示:
p> //加入_UnMapped表格与Mapped表格以获取属性
Join(_ UnMapped,x =>
$。
x.KeyColumn(UnMappedFK);
x.Map(y => y.Property,Property)
.Not.Nullable()
.ReadOnly();
});
我曾经想过创建一个视图并映射到这个属性,但是如果我能宁愿通过映射来完成。任何帮助(或解释如何连接应该工作)将不胜感激!
x.Inverse();
。 I am trying to use join to pull in a single property from another table, which doesn't have a mapping. My problem is that when I create a new instance of my mapped entity and save it I get an error about trying to insert into my unmapped table (it's trying to insert null into a not null column). I thought using .ReadOnly() would stop nhibernate from trying to insert into my unmapped table but that doesn't seem to work.
My mapping looks like this:
// Join _UnMapped table with Mapped table to get the property
Join("_UnMapped", x =>
{
x.Fetch.Join();
x.KeyColumn("UnMappedFK");
x.Map(y => y.Property, "Property")
.Not.Nullable()
.ReadOnly();
});
I have thought about creating a view and mapping to that to get this property, but if I can I would rather do it through a mapping. Any help (or an explanation on how join is supposed to work) would be greatly appreciated!
Use x.Inverse();
.
Here is some documentation about join.
这篇关于流利的nHibernate Join就是插入到连接的表中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!