[英]SQL SERVER - Timeout expired. The timeout period elapsed prior to completion of the operation or the server is not responding
[英]EntityCommandExecutionException:Timeout expired. The timeout period elapsed prior to completion of the operation or the server is not responding
我有一个EntityFramework select语句,该语句返回一些50K行。 我正在为这个简单的选择命令获得此异常
var db = new DBEntity();
db.CommandTimeout = 350;
var actCosts = (from i in db.Products
where i.productID== productID
select i).ToList();
该数据库位于Azure中。 我已经通过SSMS进行了连接,以了解检索所有数据花费4:30分钟所需的实际时间。 所以我将Commandtimeout设置为350秒。 但这没用
上面和这个之间有什么性能上的区别
var actCosts = db.Products.Where(t => t.productID== productID).ToList();
首先尝试运行.FirstOrDefault(),看看它是否及时返回数据
var actCosts = (from i in db.Products
where i.productID== productID
select i).FirstOrDefault();
如果可行,我建议设置更大的超时,例如1000,然后查看是否返回结果。
我相信SSMS使用其他方式来检索数据,并且可能比简单的.ToList()方法更好地进行了优化。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.