我有一张员工桌子和EmployeeCourseStatus
桌子。
我想显示每个员工的列表以及完成的课程数(status = "CMP"
)。
我有以下相关子查询,导致以下错误:
var query = (from emp in Employee
join adr in EmployeeAddress on emp.id = adr.EmployeeID
select new
{
id = emp.id,
name=emp.name,
country=adr.country,
CompletedCourseCount = (from c in employeeCourseStatus where c.empid = emp.id && c.status == "CMP" select c.id).count()
}
错误:
仅支持 Premitive 类型。
等效的 SQL 子查询将是 -
Select emp.id
, emp.name
, adr.Country
, CompletedCourseCount = (select count(id) from EmployeeCourseStatus where id = emp.id and status = "CMP")
from Employee emp
JOIN employeeaddress adr ON adr.EmployeeID = emp.ID