I have been having a problem with a query against a SQL Server database timing out after 30 seconds. To address this I am now setting the Command timeout. However, I am still receiving a timeout exception after 30 seconds.
If this code is executed when SelectAsync is called and since I call SetCommandTimeout() on the connection then it seems that CommandTimeout that I have just set should be used and not the OrmLiteConfig default?
OK - I’ve cloned the repo and written a test and, by stepping through the code, can see that even though I am calling SetCommandTimeout(180) the actual command timeout is being taken from OrmLiteConfig.CommandTimeout i.e. 30 seconds.
Can I ask in what cases does SetCommandTimeout have an effect?
[Test]
public async Task Can_Set_CommandTimeout()
{
using (var db = OpenDbConnection())
{
db.DropAndCreateTable<Poco>();
db.SetCommandTimeout(180);
await db.SelectAsync<Poco>().ConfigureAwait(false);
Assert.AreEqual(((OrmLiteConnection)db).CommandTimeout, 180);
}
}
@mythz can the assignments to CommandTimeout in the dbCmd extensions be removed? The timeout is already set in the exec filter - which only sets it to the default if it doesn’t have a value.