开发者

nHibernate 3 QueryOver with compound from clause

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜