这是包含有关部门信息的部门表
Dept_Id
Dept_Name
Dept_Desc
这是employees
包含有关员工信息的表。
Emp_Id
Emp_Name
Emp_Desc
Emp_Salary
返回多个结果集的存储过程,两个结果集都不能映射到任何现有的 dto:
Create procedure MyProcedure
(@DId int)
As
Begin
Select
Dept_Id, Dept_name, dept_desc,
count (e.Emp_Id) as ‘TotalEmpInDepartmentNo’
From
departments d
Join
Employees e On d.dept_id = e.dept_id
Where
d.dept_id = @DId
Select *
from products
Where dept_id = @dept_id
End
go
复杂的 dto 包含有关类别的信息。
public int Dept_Id { get; set; }
public string Dept_Name{ get; set; }
public string Dept_Desc{ get; set; }
public int Count { get; set; }
// Count represents total no of employees in each dept
public IEmployeeDTO IList<IEmployeeDTO> EmployeesList { get; set; }
//list represents employees list corresponding to the particular department
包含特定员工信息的员工 dto
public int Emp_Id{ get; set; }
public string Emp_Name{ get; set; }
public string Emp_Desc{ get; set; }
public string Emp_Salary{ get; set;}
第一个结果集包含一行,其中包含有关部门的信息
department id
name
desc
count --> total no of employees in this dept
第二个结果集包含多行属于该特定部门的员工。
我想通过实体框架代码调用该过程。
我想在里面做两件事:
现在我想使用 entityConverter 将第一个结果集映射到 complexDTO 的起始四个属性
我将为第二个结果集中的每一行创建一个单独的employeeDTO,并在从 entityconverter 转换该 DTO 后,将该 EmployeeDTo 添加到列表中。