Reputation: 111
Can we set dynamically the Command TimeOut is "Time of the query execution" in entity framework?
Upvotes: 0
Views: 554
Reputation: 11327
This way:
using (var context = new EntityContext())
{
context.Database.CommandTimeout = 300;
}
EDIT: Answer comment
Based on CURD statements, I want set Timeout Limit
I'm not sure which EF version you are using since you flagged EF6, EF5 and EF4.
I will assume in my answer EF6
You can use DbCommandInterceptor: https://www.entityframeworktutorial.net/entityframework6/database-command-interception.aspx
To check the CommandText
and set the CommandTimeout
based on it.
Upvotes: 1