如何使用 Entity Framework 将此查询转换为 linq to entities:
SELECT customer_id,
customer_name,
customer_code
FROM dbo.V_STF_CUSTOMER
WHERE company_id=@company_id AND
ORDER BY CASE
WHEN ISNUMERIC(customer_name)=1 THEN 1
ELSE 0
END,
customer_name
我有这个:
return CUstomers.GetQuery().
Where(x => x.CompanyId == companyId).
OrderBy(??This is my problem??);
我不知道怎么翻译orderby。有什么想法吗?
最佳答案
return Customers.GetQuery().
Where(x => x.CompanyId == companyId).
OrderBy(x=> SqlFunctions.IsNumeric(x.customer_name)).
ThenBy(x=> x.customer_name);
关于c# - 实体 orderby 的 linq,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6106812/