Fluent nHibernate Join is doing insert into joined table

℡╲_俬逩灬. 提交于 2019-12-23 09:51:08

问题


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!


回答1:


Use x.Inverse();.

Here is some documentation about join.



来源:https://stackoverflow.com/questions/6836949/fluent-nhibernate-join-is-doing-insert-into-joined-table

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!