session.Query<Topic>().FetchMany(x=>x.Votes)
Is that what you are looking for?
On Monday, April 30, 2012 10:30:43 PM UTC+3, s-stude wrote:
>
> Hi all.
>
> I have next entities:
>
> class Topic
> {
>
> public virtual int Id {get; private set;}
>
> public virtual ICollection<Vote> Votes {get; private set; }
>
> }
>
> class Vote
> {
>
> public virtual Topic Topic {get; private set;}
> public virtual VoteType VotedTo {get; private set;} // enum VotedUp,
> VotedDown
>
> }
>
> I need to load from the db the next info - all topics (IDs, actually
> Names, but in this demo case it does not matter) and two more fields
> CountOfVotedUp, CountOfVotedDown (aggregates). So as I understand in SQL
> world we need joins, group by, case and count.
>
> Is it posible to get this info with LINQ with less operations with db? I
> mean N+1, additional selects, connections etc.
>
> All that I tried - is to use NH's LINQ, but it's Query<Topic> aggregates
> only on Topic.Id and I could not count any of Votes collection.
>
> If I was able to explain what I want please write your version of this
> query, in other case ask me more details.
>
--
You received this message because you are subscribed to the Google Groups
"nhusers" group.
To view this discussion on the web visit
https://groups.google.com/d/msg/nhusers/-/NKMlyvnqrwYJ.
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.