简体   繁体   English

Linq to SQL for groupby给超时

[英]Linq to sql for groupby giving timeout

In the below linq query first query is running fine. 在下面的linq查询中,第一个查询运行良好。

1) var vrtemp = from details in context.GetQueryable<vw_FetchDTR>()
                                where details.App == id.ToString() 
                                select details;

but when I apply the groupby in the result of first query it's showing timeout. 但是当我在第一个查询的结果中应用groupby时,它显示超时。

2) var vrdetails = vrtemp.GroupBy(x => x.CompName);

note: vw_FetchDTR is a view 注意:vw_FetchDTR是一个视图

Maybe Linq to Sql generated not effective Sql query? 也许Linq to Sql生成的SQL查询无效? You can try to fetch all data before apply GroupBy operation. 您可以尝试在应用GroupBy操作之前获取所有数据。 Like this: 像这样:

var vrdetails = vrtemp.ToList().GroupBy(x => x.CompName); var vrdetails = vrtemp.ToList()。GroupBy(x => x.CompName);

In that case you run GroupBy operation on server side. 在这种情况下,您需要在服务器端运行GroupBy操作。 It will increase volume of transferred data but it can work more effective on Sql server 它将增加传输的数据量,但可以在Sql Server上更有效地工作

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM