简体   繁体   中英

Linq to sql for groupby giving timeout

In the below linq query first query is running fine.

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.

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

note: vw_FetchDTR is a view

Maybe Linq to Sql generated not effective Sql query? You can try to fetch all data before apply GroupBy operation. Like this:

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

In that case you run GroupBy operation on server side. It will increase volume of transferred data but it can work more effective on Sql server

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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