想要一周的efcore sql语法,流畅的api方法

时间:2018-05-19 11:11:47

标签: ef-fluent-api

Department {int Id,string Title,Staffs}

Staff {int Id,string Name,int DeptId}

var DeptStaff = 
from dept in _context.Departments 
select new 
{ 
   Department= dept, 
   StaffCount = 
      (from staff in _context.Staffs 
       where staff.DeptId == dept.Id 
       select staff).Count()
}

Staffs是Department类中的导航属性 在内部查询中给出错误

0 个答案:

没有答案