0

如何为以下 SQL 查询语句编写流畅的 nhibernate 查询:

select iseat.companynr, mdata.Employeenr from IDepartment as iseat inner join 
Employee as i on i.pkey = iseat.employeefk 
inner join employeedata as edata on edata.employeefk = i.pkey

我已经创建了类IDepartmentEmployee并且Employeedata还创建了一个类CompanyNr2EmployeeNrMap,其中包含 2 个属性CompanyNrEmployeeNr.

该查询需要将 companynr 列表作为参数并返回CompanyNr2EmployeeNrMap.

4

1 回答 1

1
var query = from emp in session.Query<Employee>()
            from department in emp.Departments
            select new CompanyNr2EmployeeNrMap
            {
                CompanyNr = department.CompanyNr,
                EmployeeNr = emp.Data.EmployeeNr
            };

return query.ToList();
于 2013-09-26T14:33:33.307 回答