如何将我的查询从MySQL转换为LINQ?

时间:2012-10-04 07:52:10

标签: c# mysql linq

如何将此查询从MySQL转换为LINQ?

SELECT SUM(IF(x>0, c*(x/100),20.00)) AS x1 
FROM tablename 
WHERE uid="some value" AND name='some value';

2 个答案:

答案 0 :(得分:2)

var sum =
    testlist.Where(item => item.name == "somevalue" && item.uid == "somevalue")
    .Sum(c => c.x > 0 ? c.c*(c.x/100) : 20);

试试这个

答案 1 :(得分:0)