1

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://

3 Answers 3

3

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() } 
Sign up to request clarification or add additional context in comments.

Comments

0

You've specified the query correctly in linq. NHibernate is refusing to translate it.

1 Comment

Hmmm - is there a way i can do this in HQL?
0

I just copied your query with a slightly different domain and it worked. But that will count StageSets by Act, NOT favorites.

Comments