aggregate - NHibernate - Eager loading grouped object when aggregating -


i have following code aggregating auction statistics statistics table , returning auction summed counts (there may multiple rows in statistics table per auction...)

   var stats = _session.queryover<auctionstatistic>()        .select(            projections.group<auctionstatistic>(s => s.auction),            projections.sum<auctionstatistic>(s => s.bidcount),            projections.sum<auctionstatistic>(s => s.viewcount),            projections.sum<auctionstatistic>(s => s.searchcount)        )        .orderby(projections.sum<auctionstatistic>(s => s.applicationcount)).desc        .fetch(x => x.auction).eager        .take(take)        .list<object[]>(); 

the query seems work fine - except auction returned evaluated lazily, causing select n+1 scenario. can provide suggestions how field can evaluated eagerly?

thanks in advance

jp

the brute force way (similar sub-select):

_session.queryover<auction>().whererestrictionon(a => a.id).isin(stats.selectmany(s => s).oftype<auction>().select(a => a.id).toarray()); 

Comments

Popular posts from this blog

objective c - Change font of selected text in UITextView -

php - Accessing POST data in Facebook cavas app -

c# - Getting control value when switching a view as part of a multiview -