var customers = (from c in session.Query<Customer>()
from o in c.Orders
from l in o.OrderLines
where l.Product.Id == 123)
.FetchMany(c => c.Orders)
.ThenFetchMany(o => o.OrderLines).ToList();
or
var customers = session.Query<Customer>()
.Where (c => c.Orders.Any (o => o.OrderLines.Any (l =>
l.Product.ID == 123)))
.FetchMany(c => c.Orders)
.ThenFetchMany(o => o.OrderLines).ToList();
both not tested, but at least the first one should work with NH. the
second one might result in strange SQL.
On Mar 15, 7:28 pm, David McClelland <[email protected]>
wrote:
> I am testing queries using the new LINQ to NHibernate provider from
> 3.0 following Mike Hadlow's examples:
>
> http://mikehadlow.blogspot.com/2010/08/nhibernate-linq-eager-fetching...
>
> His final example is:
>
> var customers = session.Query<Customer>()
> .FetchMany(c => c.Orders)
> .ThenFetchMany(o => o.OrderLines).ToList();
>
> How would I add a Where condition to this LINQ query to allow me to
> retrieve Customers who had placed orders for Product.Id = 123?
--
You received this message because you are subscribed to the Google Groups
"nhusers" 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/nhusers?hl=en.