Ok Mauricio, I followed your suggestion and got the new version of AR
working. However I still don't know how to solve my problem :(

Do I just have to add another DetachedCriteria (to fetch the second
collection) to the MultiCriteria? This gives me strange results:

DetachedCriteria dc = DetachedCriteria.For<File>();
dc.SetResultTransformer(new DistinctRootEntityResultTransformer());
dc.SetFetchMode("ComplaintCause", FetchMode.Eager);
dc.SetFetchMode("InsuranceType", FetchMode.Eager);
dc.SetFetchMode("Applicants", FetchMode.Eager); // MANY-TO-MANY
COLLECTION

DetachedCriteria dc2 = DetachedCriteria.For<File>();
dc2.SetResultTransformer(new DistinctRootEntityResultTransformer());
dc2.SetFetchMode("Insurers", FetchMode.Eager); // THE ADDITIONAL
COLLECTION TO EAGER LOAD

ISession session = ActiveRecordMediator.GetSessionFactoryHolder
().GetSessionFactory(typeof(File)).OpenSession();
IMultiCriteria mCriteria = session.CreateMultiCriteria();
mCriteria.Add(dc);
mCriteria.Add(dc2);

IList files = mCriteria.List();

I'm really confused, any help would be highly appreciated.


On 2 Cze, 04:08, Mauricio Scheffer <[email protected]> wrote:
> You're probably using NHibernate 1.2
> Upgrade to a newer AR/NHibernate
>
> http://mortslikeus.blogspot.com/2009/05/activerecord-alpha-release.html
>
> On Jun 1, 8:23 pm, Cosmo <[email protected]> wrote:
>
> > Thanks Mauricio - this should work. However I can't find this method -
> > only CreateMultiQuery() exists.
>
> > Any suggestions?
>
> > On 2 Cze, 01:07, Mauricio Scheffer <[email protected]> wrote:
>
> > > CreateMultiCriteria
>
> > >http://www.nhforge.org/doc/nh/en/index.html#performance-multi-criteria
>
> > > On Jun 1, 7:25 pm, Cosmo <[email protected]> wrote:
>
> > > > Correct, but how can I achieve this by using DetachedCriteria?
>
> > > > On 1 Cze, 23:54, Christian Wuerdig <[email protected]> wrote:
>
> > > > > You probably want 
> > > > > this:http://ayende.com/Blog/archive/2007/06/20/Efficently-loading-deep-obj...
>
> > > > > -------- Original Message --------
> > > > > Subject: [AR] Detached Criteria - Eager Loading
> > > > > From: Cosmo <[email protected]>
> > > > > To: Castle Project Users <[email protected]>
> > > > > Date: 6/2/2009 8:32 AM
> > > > > > I have a class with two many-to-many associations. After reading the
> > > > > > docs I realised that I'm allowed to get only one collection. So how 
> > > > > > is
> > > > > > it possible to get all collections with eager loading?
>
> > > > > > So far...
>
> > > > > > DetachedCriteria dc = DetachedCriteria.For<File>();
> > > > > > dc.SetResultTransformer(new DistinctRootEntityResultTransformer());
> > > > > > dc.SetFetchMode("ComplaintCause", FetchMode.Eager);
> > > > > > dc.SetFetchMode("InsuranceType", FetchMode.Eager);
> > > > > > dc.SetFetchMode("Applicants", FetchMode.Eager); // MANY-TO-MANY
>
> > > > > > Now I would like to get another collection:
> > > > > > dc.SetFetchMode("Insurers", FetchMode.Eager); // MANY-TO-MANY
>
> > > > > > But this gives me strange results. Is it possible to use a 
> > > > > > MultiQuery,
> > > > > > or is there even a better way to go?
>
> > > > > > Thanks for your help in advance.
> > > > > > Cosmo
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Castle Project Users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/castle-project-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to