How do you set Command Timeout in Linqpad?

As mentioned in @DaveShaw's answer when querying a SQL Server database in LinqPAD using a 'regular' connection, you can use:

this.CommandTimeout = 60

However, this property is not available when LinqPad connects to DB using an EF-library. Using this.CommandTimeout results in:

'UserQuery' does not contain a definition for 'CommandTimeout' and no extension method 'CommandTimeout' accepting a first argument of type 'UserQuery' could be found (press F4 to add a using directive or assembly reference)

Some puzzling and a this answer about EF time-outs in general led me to use this on an EF-connection:

(this as IObjectContextAdapter).ObjectContext.CommandTimeout = 60;

I have run queries that have taken minutes and never had a command time out. That said, here's how you change it...


All of the work you perform inside a UserQuery. The CommandTimeout is a property of that.

this.CommandTimeout = 60;

Have a look at all the properties under this. It gives you a nice insight into some of the things you can do.