Select n+1 problem
- by Arnis L.
Foo has Title.
Bar references Foo.
I have a collection with Bars.
I need a collection with Foo.Title.
If i have 10 bars in collection, i'll call db 10 times.
bars.Select(x=x.Foo.Title)
At the moment this (using NHibernate Linq and i don't want to drop it) retrieves Bar collection.
var q = from b in Session.Linq<Bar>()
where ...
select b;
I read what Ayende says about this.
Another related question.
A bit of documentation.
And another related blog post.
Maybe this can help?
What about this?
Maybe MultiQuery is what i need? :/
But i still can't 'compile' this in proper solution.
How to avoid select n+1?