如何减少LINQ查询的执行时间 [英] How to reduce excution time of a LINQ Query

查看:88
本文介绍了如何减少LINQ查询的执行时间的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述





我有一张桌子,有超过300条记录。

我正在为每条记录做操作LINQ。但它会挂起。



Hi,

I have one table in that there are more than 300 records.
I am doing operation for each record using LINQ. But it gets hang.

var qryCkeckClocked = (from a in
                                             context.sp1
                                         select a);
foreach (var scan in qryCkeckClocked)
                    
var stud = (from ***
}



这是我的代码。

我认为查询可以不用迭代到SQL。

请建议我


This is my code.
I think the query excutes with no of iteration to SQL.
Please suggest me

推荐答案

如果你想使用join两个表使用LINQ的Join函数而不是foreach。这个查询将创建像
$ b这样的sql命令$ b
If you want to use join two table use Join function of LINQ instead of foreach. This query will create sql command like
Select * from context.sp1





因此,您只能选择所需的表,而不是*,这也会缩短查询执行时间。



So instead of * you can select only desired table this will also reduce query execution time.


这篇关于如何减少LINQ查询的执行时间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆