执行以下代码时出错 错误:无法评估表达式,因为代码已优化或本机框架位于调用堆栈之上
public ICollection<Employee> GetEmployeeDataList(RetriveEmployeeDetailsOnEntity request)
{
ICollection<Employee> returnValue = null;
SectionManagerHr.Execute(() =>
{
using (var tx = _Dao.Session.BeginTransaction())
{
var query = getEmployeeDataQuery(request);
returnValue = query.List();
tx.Commit();
}
});
return returnValue;
}
private IQueryOver<Employee> getEmployeeDataQuery(RetriveEmployeeDetailsOnEntity request)
{
Employee employee = null;
EmployeeData employeeData = null;
EmployeePayrollDefinition employeePayrollDefinition = null;
var query = _Dao.Session
.QueryOver(() => employee)
.JoinAlias(() => employee.EmployeeDataList, () => employeeData, JoinType.LeftOuterJoin)
.JoinAlias(() => employee.EmployeePayrollDefinitionList, () => employeePayrollDefinition, JoinType.LeftOuterJoin)
.TransformUsing(Transformers.DistinctRootEntity)
.Where(() => employee.CompanyEntityId == request.EntityId);
return query;
}
答案 0 :(得分:0)
我想说,你得到的例外就是解决真正的问题:
NHibernate.QueryException:无法同时获取多个行李。
因为我希望这些是集合:
employee.EmployeeDataList // expect it is a IList<EmployeeData>
employee.EmployeePayrollDefinitionList // IList<EmployeePayrollDefinition>
并且它们都不能在一个查询中使用。
我建议使用某种批量提取: