我有一个c#代码如下
var deptSalesQuery =
from d in db.DashboardFigures
join s in outlets.Split(',').Select(x => int.Parse(x)) on d.OutletNo equals s
where (d.TypeOfinformation == "SALES")
group d by new
{
d.Number
} into newGroupedresult
select new DeptSales()
{
Dn = (int)newGroupedresult.Key.Number,
Qs = (double)newGroupedresult.Sum(d => d.Value_4),
Se = (double)newGroupedresult.Sum(d => d.Value_2),
Si = (double)newGroupedresult.Sum(d => d.Value_3)
+ (double)newGroupedresult.Sum(d => d.Value_2)
};
当我将Outlets =" 1,2,3,4,....一直传到110"时,软件崩溃告诉我嵌套语句太多了。
有什么办法可以删除JOIN并在WHERE子句中添加一些内容来帮助解决这个问题吗?
由于
答案 0 :(得分:1)
由juharr撰写,在查询之前执行:
int[] splitted = outlets.Split(',').Select(int.Parse);
并在查询中:
where splitted.Contains(d.OutletNo) && d.TypeOfinformation == "SALES"