1

有没有人知道使用 nHibernate 3 QueryOver 语法从子句中进行复合的方法 - 使用 Linq to objects 是可能的。我知道使用 Linq To nHibernate 是可能的,但我仍在努力了解 queryover api。

下面是取自 msdn 的 Linq to 对象示例:

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

取自MSDN

4

1 回答 1

3

您可以使用 QueryOver API 加入,但我认为您需要使用 Linq to Objects 将结果展平为匿名类型。

像这样的东西:

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 });
于 2011-04-29T17:48:35.153 回答