nHibernate 3 QueryOver with compound from clause

1.7k Views Asked by At

Does anybody know a way to do compound from clauses - that are possible with Linq to objects - with nHibernate 3 QueryOver syntax. I know its possible with Linq To nHibernate, but I'm still trying to get my head around the queryover apis.

Here is the example taken from the msdn for Linq to objects:

var scoreQuery = from student in students
                 from score in student.Scores
                 where score > 90
                 select new { Last = student.LastName, score };

Taken from MSDN

1

There are 1 best solutions below

0
On BEST ANSWER

You can join using the QueryOver API, but I think you'll need to use Linq to Objects to flatten your result into the anonymous type.

Something like this:

session.QueryOver<Student> ()
    .JoinQueryOver (s => s.Scores).Where (s => s > 90)
    .Select (s => s.LastName, s => s.Scores)
    .List ()
    .SelectMany (s => s.Scores, (student, score) => new { Last = student.LastName, Score = score });