ServiceStack OrmLite Command Timeout

c#, ormlite-servicestack, servicestack

Solution

With the most recent change OrmLite no longer provides APIs around the `IDbCommand` object directly (which have now all been made internal in the latest version).

But since OrmLite is only extension methods over ADO.NET's underlying IDbConnection and IDbCommand interfaces, you can easily by-pass OrmLite's extension methods when you need to and just use them directly, e.g:

IDbConnection db = ConnectionFactory.OpenDbConnection();
IDbCommand cmd = db.CreateCommand();
cmd.CommandTimeout = 240;  
cmd.CommandText = "...";
cmd.ExecuteNonQuery();

Alternatively you can set a global CommandTimeout with:

OrmLiteConfig.CommandTimeout = 240;

Problem

When using IDbConnection.ExecuteSql how do I set the Command Timeout? ``` IDbConnection db = ConnectionFactory.OpenDbConnection(); db.ExecuteSql("..."); ``` If I use the IDbCommand.ExecuteSql ( See below ) method I can set the Command Timeout, but I get a bunch of warnings about deprecated methods. ``` IDbCommand comm = db.CreateCommand() comm.CommandTimeout = 240; comm.ExecuteSql("..."); ```

Original source

Related problems