I\'m using the current Linq provider for NHibernate (version 2.1).
I have two entities: VideoGame and GameDeveloper, with a many-to-one relationship between them. I\'m t
How about
from v in session.Linq<VideoGame>()
group by v.Developer into developerGroup
select new {key = developerGroup.Key, count = developerGroup.Count()}
Seems like group by
is broken in the 2.1 NHibernate LINQ provider. A while ago Steve Strong blogged that group by
is in the trunk so if you are feeling adventurous enough and not willing to wait on 3.0 then that could be an option.
Or you could use a brute force solution something like this
from v in (from vg in session.Linq<VideoGame>() select vg).ToList()
group by v.Developer into developerGroup
select new {developerGroup.Key.Name, Count = developerGroup.Count()};