SqlMapper global/default CommandTimeout - #284
Conversation
…class will hold some "global" settings, which the SqlMapper will use.
…t value when the CommandDefinition commandTimeout property is not set.
SqlMapper global/default CommandTimeout
|
@mgravell Thanks Marc! |
|
How is this used? Link is broken |
|
Found it ex. (from https://stackoverflow.com/questions/15683197/weird-timeout-issues-with-dapper-net/32524428#32524428) |
|
@perragradeen Link above has been updated. The sample class explains how to subclass/inherit the This Pull Request has already been merged into Dapper, so if you're using Dapper, you can simply set The more granular option, as you demonstrated above, is to specify the timeout on each query or command independently. |
|
I cannot find "Settings" in the static Class Dapper.SqlMapper |
|
@perragradeen This pull requests is targeted for the 1.5.0 release of Dapper. If you use NuGet, you should be able to use the beta package (though betas are usually not recommended for production use): https://www.nuget.org/packages/Dapper. |
|
I should note that we're dogfooding the beta in production at On Mon, 14 Dec 2015 21:09 Jesse notifications@github.com wrote:
|
|
I really want to rename these, with a unit. e.g. |
|
@NickCraver feel free to change it. I created the original PR, and since it's in beta, I am probably one of the very few using it. |
|
IMO: if this is only in the beta - we can do this. On 15 December 2015 at 01:38, Nick Craver notifications@github.com wrote:
Regards, Marc |
The way this new property works is by looking at the nullable
commandTimeoutparameter passed to theCommandDefinitionclass, and if null, use the newCommandTimeoutSetting.Dapper works via Extension Methods, which are static, therefore not allowing instantiated versions to hold different values. I find that this is OK, given that the option to specify the Command Timeout is provided on each call to
Execute,ExecuteReader,Query, andQueryMultiple.An alternative, which I currently use, but do not like the additional layer is as follows:
DbConnectionCreateDbCommand(which is more involved)CreateDbCommand, hold the return value in a variable, modify theCommandTimeoutproperty as desired, and return itAdditional discussion on Issue #282.
I hope this initial design helps pave the way for additional settings and features.