8,497
社区成员
发帖
与我相关
我的任务
分享
select '收入' as kemu,isnull(sum(money),0)as money
from [statistics]
where SortType =1 and SortId in (
select Id from CashflowSort where CorpMoneySign =1)
//针对上边的SQL 语句,我写了下边的LINQ
var listID=from c in CashflowSort
where c.CorpMoneySign ==1
select c.Id;
var query= from s in statistics
group s by s.money into t
where s.SortType ==1
&& listID.Contains(s.SortId)
select new
{
kemu='收入',
money=t.Sum(t=>t.money)==null?0:t.Sum(t=>t.money)
}
select new
{
收入 = s.kemu,
money= statistics.Sum(a=> a.money)==null?O:statistics.Sum(a=> a.money))
}