I have a table (UncommittedVideoFile
) that has a strict one-to-one relationship with a different table (VideoOrImageAsset
). When I load an UncommittedVideoFile, I want to load the VideoOrImageAsset in the same query via a JOIN. (Inner or left outer).
Apparently it's possible to specify fetch-by-join when you use xml mapping: https://ayende.com/blog/3960/nhibernate-mapping-one-to-one
It's also possible if you are using Fluent NHibernate: https://stackoverflow.com/a/15694723/25216
But using MappingByCode, is is possible to set a Fetch option? I can't see one anywhere.
Here is the code that I currently have. The IOneToOneMapper
interface does not have a Fetch
method.
classMapper.OneToOne(
f => f.VideoOrImageAsset,
oneToOneMapper =>
{
oneToOneMapper.Constrained(true);
oneToOneMapper.ForeignKey("Id");
oneToOneMapper.Lazy(LazyRelation.NoLazy);
}
);
It's known missing mapping-by-code feature GH-2139. And it's already implemented in 5.3 (not yet released, but pretty close)
For now you can use pre-release version of 5.3 from https://www.myget.org/gallery/nhibernate (also check notes how to use it here)