Load collections eagerly in NHibernate using Criteria API -


Text after "div class =" itemprop = "text">

I have a unit which is HasMany institutions B and institutions C All institutions A, B and C have some references X, Y and J should be eagerly loaded.

I want to read all the entities from the database, and eagerly want to load the archives using the benchmark API. So far, I am able to bring references in 'A' curiosity. But when the archives are loaded, the references within them are loaded lazily.

How do I do this here

  AllEntities_A = _session.CreateCriteria (typeof (A)). SetFetchMode ("x", FetchMode.Eager) .SetFetchMode ("y", FetchMode.Eager) .List & lt; A & gt; () AsQueryable () .;  

Using dissatisfaction, the mapping of the unit A is as shown below. _B and _C B & amp; Are private IList for; Respectively A.

  id (c => c.SystemId); Version (c => c. Version); Reference (C => C. X). Pebble all (); Reference (C => C). Pebble all (); HasMany & lt; P & gt; (Reveal.Property & lt; a & gt; ("_b")) .AsBag () .Cascade.AllDeleteOrphan () .Not.LazyLoad () .Inverse () .Cache.ReadWrite () IncludeAll () .; HasMany & LT; C & gt; (Reveal.Property & lt; a & gt; ("_C")) .AsBag () .Cascade.AllDeleteOrphan () .LazyLoad () .Inverse () .Cache.ReadWrite () IncludeAll () .;  

I do not want to change the mapping file, and I would like to load the entire unit with a stern point i.e. where I should get a list of B and the list of C and whose reference properties are also impatient

After

You are trying to do the Cartesian product here I think that relation to NHibernate Need to match in the form of bags instead of set Since the bags allow duplicates.

Anyway, Cartesian products are very inefficient. Instead of using a multi query or future query, see

:.


  • Comments