Thanks for this answer but it's not what I wanted to obtain.
If I do this :
var query = from thirdParty in Session.Query<ThirdParty>() where
Assignments.Any(assignment => assignment .EndDate == null )
select thirdParty;
The Assignments collection will be filled entirely. In some cases, I
would like that the Assignments collection contain only the assignment
where EndDate == null. It's not necessary to get all the records of
the child collection because I want only the last assignment. I don't
know how I can do this in LINQ.
On 8 déc, 00:52, Mohamed Meligy <
eng.mel...@gmail.com> wrote:
> Did you try:
>
> var query = from thirdParty in Session.Query<ThirdParty>() where
> Assignments.Any(assignment => assignment .EndDate == null )
> select thirdParty;
>
> Depends on whether NHibernate LINQ provider supports Any() like this. Not
> sure about it.
>
> Check also the QueryOver API. Feels a lot like LINQ (when called using
> methods not LINQ syntax). They have WhereRestrictionOn() method, you may use
> it to add IN restriction on the Assignments (passing it different
> QueryOver<Assignment>() query, again, not sure if that will work also).
>
> One other way is to do JOIN and only select ThirdParty, then put the query
> in brackets and add DISTINCT like (from ... select ...).Distinct()
>
> *Mohamed Meligy
> *Readify | Senior Developer
>
> M:
+61 451 835006 | W:
www.readify.net
> [image: Description: Description: Description: Description: rss_16] [image:
> Description: Description: Description: Description:
> cid:image003....@01CAF81D.6A076510]
> <
http://www.linkedin.com/in/meligy> [image:
> Description: Description: Description: Description:
> cid:image005....@01CAF81D.6A076510] <
http://twitter.com/meligy>
> <
http://www.greatplacetowork.com.au/best/best-companies-australia.php><
http://www.readify.net/AboutUs/NewsItem.aspx?id=10>
> >
nhusers+u...@googlegroups.com<
nhusers%2Bunsu...@googlegroups.com>
> > .
> > For more options, visit this group at
> >
http://groups.google.com/group/nhusers?hl=en.- Masquer le texte des messages précédents -
>
> - Afficher le texte des messages précédents -