Pergunta

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

Foi útil?

Solução

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 });
Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top