开发者

nHibernate 3 QueryOver with compound from clause

开发者 https://www.devze.com 2023-03-01 04:53 出处:网络
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

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.

H开发者_开发知识库ere 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


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 });
0

精彩评论

暂无评论...
验证码 换一张
取 消