我的代码中有以下情况,无法解决。情况-
var grpA = Session.QueryOver(() => _employeeGroupRelation));
var grpB = Session.QueryOver(() => _employeeGroup));
// var grpC should join grpA and grpB on _employeeGroupRelation.groupID = _employeeGroup.ID 问题--是否有办法使用grpA和grpB语法连接QueryOver?在不使用grpA或grpB上的List()的情况下,是否可以做到这一点,因为每个记录都将保存近10,000条记录,我不想将它们转储到内存中。这是QueryOver的正确使用吗?有没有更干净的方法来实现我想要解决的问题?
这可能是一个基本的疑问,但我是NHib和QueryOver的新手。
编辑-
select * from employeeGroup a
inner join employeeGroupRelation b on a.ID = b.ID 这就是我在SQL中要做的。
发布于 2012-03-27 21:01:17
最简单的方法是:
session.QueryOver<EmployeeGroup>()
.JoinQueryOver(employeeGroup => employeeGroup.EmployeeGroupRelation)
.Take(1000) // The same as top in SQL, if you don't want load all of entities
.TransformUsing(Transformers.DistinctRootEntity)
.List();"JoinQueryOver“将"EmployeeGroup”和相关的"EmployeeGroupRelation“作为LazyLoad的代理(取决于映射)
如果不想使用LazyLoad,可以这样做:
session.QueryOver<EmployeeGroup>()
.Fetch(employeeGroup => employeeGroup.EmployeeGroupRelation).Eager
.Take(1000) // The same as top in SQL, if you don't want load all of entities
.TransformUsing(Transformers.DistinctRootEntity)
.List();获取"EmployeeGroup“和相关的"EmployeeGroupRelation”(非代理)
https://stackoverflow.com/questions/9896386
复制相似问题