对于许多嵌套语句
To many nested statements
我有一个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 子句中添加一些内容来帮助解决这个问题?
谢谢
正如 juharr 所写,在查询之前做:
int[] splitted = outlets.Split(',').Select(int.Parse);
并在查询中:
where splitted.Contains(d.OutletNo) && d.TypeOfinformation == "SALES"
我有一个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 子句中添加一些内容来帮助解决这个问题?
谢谢
正如 juharr 所写,在查询之前做:
int[] splitted = outlets.Split(',').Select(int.Parse);
并在查询中:
where splitted.Contains(d.OutletNo) && d.TypeOfinformation == "SALES"