I forget to say that you can use MultiCriteria to load in a single round 
trip to DB


Il giorno mercoledì 13 aprile 2016 22:51:52 UTC+2, Lars Halvor Anundskås ha 
scritto:
>
> Hi,
>
> This is a question regarding filtering/criterias on associated entities :)
>
> I have 3 entities:
>
> Place
> Store
> Owner
>
> A Place has many stores, a store has one owner, 
> an owner can have many stores, a store have one place.
>
> When I do a query for places I'm looking for a way to control which 
>  stores are loaded in place.Stores collection.
> For instance, I want all places, but I only want to return the store if 
> the owner is Mike.
>
> Is there any way to do this with nhibernate, using criterias or filters?
>
> I have tested multiple variants but I always get all stores related to the 
> place, for instance:
>
> Session.CreateCriteria(typeof(Place))
>                     .CreateAlias("Stores", "s", JoinType.InnerJoin)
>                 .Add(Restrictions.Eq("s.Owner", "Mike"));
>
> But I always get all stores listed, regardless of the owner.
>
> Is it possible to achieve this, how?
> Greatful for any hints/tips/solutions.
>

-- 
You received this message because you are subscribed to the Google Groups 
"nhusers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/nhusers.
For more options, visit https://groups.google.com/d/optout.

Reply via email to