Reputation:
I have the version 3.0.0.1001 nhibernate.
My objects are basically modeiling a lineup at an event. So I have a StageSet object which represents one slot in the schedule for a stage.
Each StageSet object has a Stage and an Act property.
It also has many Users - people who have favorited the set.
I'm trying to ascertain the most popular sets that have been favorited using the following linq:
var topStars = from s in Db.StageSets
group s by s.Act.Id into g
select new { SetKey = g.Key, Count = g.Count() };
However this just fails with a Could not execute query[SQL: SQL not available] error
Should I be able to do this?
w://
Upvotes: 1
Views: 2437
Reputation: 30813
in case someone comes here. The following should work with NH 3.1
var topStars = from s in Db.StageSets
group s by s.Act.Id into g
select new { SetKey = g.First().Act.Id, Count = g.Count() }
Upvotes: 3
Reputation: 52735
I just copied your query with a slightly different domain and it worked. But that will count StageSets by Act, NOT favorites.
Upvotes: 0
Reputation: 110121
You've specified the query correctly in linq. NHibernate is refusing to translate it.
Upvotes: 0