我有一个像这样的 SQL 查询:
Select
sum(case when OperationType = 1 then 1*ProductCountMain when OperationType = 2 then -1*ProductCountMain end) As Result
From Inventories
我该如何在EntityFramework Core中使用Lambda表达式编写这个代码?
我有一个像这样的 SQL 查询:
Select
sum(case when OperationType = 1 then 1*ProductCountMain when OperationType = 2 then -1*ProductCountMain end) As Result
From Inventories
我该如何在EntityFramework Core中使用Lambda表达式编写这个代码?
?:
吗?例如Inventories.Sum(i=>i.OperationType==1?ProductCountMain:-ProductCountMain)
。 - Panagiotis Kanavos