I have a (fictional) class with Fluent-mapping:
public class Customer
{
public virtual int Id { get; set; }
public virtual string Name { get; set; }
public virtual Employee Responsible { get; set; }
public virtual IList<Order> Orders { get; set; }
}
public class CustomerMapping : ClassMap<Customer
{
public CustomerMapping()
{
Id(c => c.Id);
Map(c => c.Name);
References(c => c.Responsible);
HasMany(c => c.Orders);
}
}
Now - if I fetch a customer from database the HasMany-reference is Lazyloaded, but the References-reference seems not to be lazy loaded. Is this expected? Do I need to explicitly it?
var fromDb = Session.Get<Customer>(id);
Assert.That(!NHibernateUtil.IsInitialized(fromDb.Orders));
Assert.That(!NHibernateUtil.IsInitialized(fromDb.Reponsible)); // <-- fails