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.