我想知道是否有人可以将下面的 SQL 转换为 LINQ to Entities 查询
SELECT Name, IsEmployee, IsQualityNetwork
FROM Person
ORDER BY CASE WHEN IsQualityNetwork = 1 or IsEmployee = 1 THEN 0 ELSE 1 END, Name
我尝试使用 Linq Dynamic,但是当执行此代码时:
var p = ctx.People
.OrderBy("CASE WHEN IsQualityNetwork = 1 or IsEmployee = 1 THEN 0 ELSE 1 END")
.OrderBy(e => e.Name);
我得到了例外:{“'Person'类型中不存在任何属性或字段'CASE'”}