I am using FluentNHibernate and have two classes that have a 1:1 relationship. ItemA includes
public virtual ItemB { get; set; }
and mapped with
HasOne(x => x.ItemB).ForeignKey("ItemID");
I am only interested in ItemA, but because it has the following map I'm seeing two database calls when I run:
var res = session.Query<ItemA>()
.SingleOrDefault(x => x.ItemId.ToString() =="AC3E30FF-E767-440F-AB1F-0000293C5A0C");
I get a select for ItemA table and a select for ItemB table.
If I then make a change back to References, I get only one:
References(x => x.ItemB).ForeignKey("ItemId");
This is perhaps trivial, but I have another class which has been given a number of "HasOne" relationships for tables I do not need to be using and yet Select queries are becoming rather complex.
I tried adding "Lazyload" to the mapping, but that didn't seem to change anything. Is there any way of keeping the HasOne relationship but being able to generate a simple, single "select" query for my "Query" (i.e. Select [columns] from ItemA where ItemID =...)?