Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
QueryOver 不是 LINQ。
您的第二个代码片段有效,因为它正在检索所有记录并在内存中使用 LINQ-to-objects。
你应该做的是:
session.Query<A>() .Where(a => a.B.Count() > 0) .ToList();
或者更好:
session.Query<A>() .Where(a => a.B.Any()) .ToList();
Query是扩展方法,需要添加using NHibernate.Linq;
Query
using NHibernate.Linq;