1. The dataset returned is small
2. We don't care about the cartesain product.
3. We want to load the parents
4. We want to load the children
5. We want to filter the results based on a where clause on the children
So how do we go about this, the domain model for this example looks like this:-
public class Movie : Entity { public virtual string Director { get; set; } public virtual IList<Actor> ActorList { get; set; } } public class Actor : Entity { public virtual string Name { get; set; } public virtual string Role { get; set; } }When using NHibernate and QueryOver we would specify eager loading by using:-
Actor actor = null; return Session.QueryOver<Movie>() .Fetch(f => f.ActorList).Eager .Left.JoinAlias(f => f.ActorList, () => actor) .Where(() => actor.Name.Like("m%")) .List();Lets look at the SQL output that gets generated:-
Excellent this is exactly what I require, one sql statement is sent to the database and both parents and children are hydrated at the same time.
However, there is one caveat here, look closely at my c# code and you will see that I am specifying a left join.
Now for me this is where the some confusion crops up. If I take out the .left out of my code so that it is:-
return Session.QueryOver<Movie>() .Fetch(f => f.ActorList).Eager .JoinAlias(f => f.ActorList, () => actor) .Where(() => actor.Name.Like("m%")) .List();and rerun my example the sql that gets generated is:-
As you can see we have resorted back to lazy loading, this is quite strange and I am not 100% sure if this is a bug or the intended behaviour.
So it looks like if you want to take advantage of eager loading and queryover then you always need to specify a .left join in your code!
Very good, had the same problem because the LEFT was not working
ReplyDeleteThanks. You saved my day :)
ReplyDeleteStill a useful article in 2016, thank you!
ReplyDeleteJust came across this problem, and I agree that this article is still relevant. Solved the issue I was having
ReplyDeleteGreat. Still an issue in 2017.
ReplyDeleteThanks. You saved my day in 2020 :)
ReplyDeleteAnkara
ReplyDeleteBolu
Sakarya
Mersin
Malatya
V3HS
görüntülü.show
ReplyDeletewhatsapp ücretli show
URZM
13F79
ReplyDeleteKripto Para Nedir
Ünye Organizasyon
İzmir Şehirler Arası Nakliyat
Tokat Evden Eve Nakliyat
Bartın Şehirler Arası Nakliyat
Lovely Coin Hangi Borsada
Karaman Parça Eşya Taşıma
Siirt Şehir İçi Nakliyat
Osmo Coin Hangi Borsada
209F5
ReplyDeleteAğrı Kızlarla Canlı Sohbet
Kırklareli Yabancı Canlı Sohbet
Kars Canlı Görüntülü Sohbet
bilecik mobil sesli sohbet
Karaman Ücretsiz Görüntülü Sohbet
osmaniye rastgele görüntülü sohbet ücretsiz
bedava görüntülü sohbet
afyon ücretsiz sohbet odaları
urfa canlı sohbet et
48926
ReplyDeleteKripto Para Nasıl Çıkarılır
Gate io Borsası Güvenilir mi
Coin Madenciliği Nedir
Binance Referans Kodu
Sohbet
Parasız Görüntülü Sohbet
Likee App Takipçi Hilesi
Facebook Grup Üyesi Satın Al
Soundcloud Beğeni Satın Al
E99E7
ReplyDeleteGate io Borsası Güvenilir mi
Telegram Görüntüleme Hilesi
Bitcoin Nasıl Alınır
Telegram Abone Hilesi
Star Atlas Coin Hangi Borsada
Threads Yeniden Paylaş Hilesi
Coin Para Kazanma
Baby Doge Coin Hangi Borsada
Parasız Görüntülü Sohbet
3984F
ReplyDeleteBinance Yaş Sınırı
Yeni Çıkacak Coin Nasıl Alınır
Binance Referans Kodu
Mexc Borsası Güvenilir mi
Bee Coin Hangi Borsada
Clubhouse Takipçi Satın Al
Bitcoin Nasıl Üretilir
Kripto Para Nasıl Kazılır
Mefa Coin Hangi Borsada