开发者

How can you increase timeout in Linq2Entities?

开发者 https://www.devze.com 2022-12-22 21:54 出处:网络
I\'m doing a basic select against a view.Unfortunately the result can be slow and I\'m getting timeout errors intermittently.How can I increase the timeout?

I'm doing a basic select against a view. Unfortunately the result can be slow and I'm getting timeout errors intermittently. How can I increase the timeout?

Using .NET 3.5, Sql Server 2000, Linq2Entities

I'm using the very basic query List<MyData> result = db.MyData.Where(x.Attribute == search).ToList();

Fixing the query so t开发者_如何转开发hat it's faster on the DB side is not an option here.

Exact Error: "Timeout expired. The timeout period elapsed prior to completion of the operation or the server is not responding."

Update: I'd prefer to just change it for this one query.


You can set the timeout in your connection string.

Edit (new): It turns out that there are two different timeout concepts. The connection timeout is used to determine wether or not a connection can be established. The CommandTimeout property on the object context controls timeout for commands. So just set that to a high value, and it should not influence the short-running queries in any way.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号