Collation formula in free nhibernate

I have an object called Event:

public virtual int ID { get;set;} public virtual string Name { get;set;} public virtual Event Master { get;set;} public virtual int ChildrenCount { get;set;} 

The child table is displayed:

  Map(x => x.ChildrenCount).LazyLoad().Formula("(Select count(*) from Events Where Events.Master_id=Event_id)"); 

Sometimes I want now the value of ChildrenCount and set the Fetchmode to Eager

  store.SetFetchMode("ChildrenCount",NHibernate.FetchMode.Eager); 

But the system is still lazyloads.

Any help?

+4
source share
1 answer

You can use the "fetch all properties" tooltip in HQL:

 from Event fetch all properties 

This will load all your lazy properties.

0
source

Source: https://habr.com/ru/post/1395560/


All Articles