在我的代码中使用ASP.CORE上下文的新功能,我希望使用ASP.CORE Context转换此T-SQL语句
SELECT ID, SchemeCode, Name
FROM Scheme SM
WHERE
SM.ParentID = 1
AND sm.[ID]
IN (SELECT dd.[Scheme_id]
FROM dbo.[Employer_Detail] dd
INNER JOIN dbo.[Employer] er ON dd.Employer_id = er.Employer_id
WHERE er.Employer_Parent_id = 123)
答案 0 :(得分:0)
已解决
var npSchemes = from scheme in _context.Schemes
join ded in _context.DeductionCodes on scheme.Id equals
ded.SchemeId
join er in _context.Employers on ded.EmployerId equals
er.Id
where scheme.ParentId == parentId && er.ParentId == employerId
select new {scheme.Id, scheme.Code, scheme.Name};
var result = npSchemes.GroupBy(sm => sm.Id).Select(grp =>
grp.First()).ToList();