zain85 / dapper-dot-net

Automatically exported from code.google.com/p/dapper-dot-net
Other
0 stars 0 forks source link

Support for custom modifications of IDbCommand instance #80

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
I want to use SqlDependency with Dapper, unfortunately I cannot inject any sort 
of custom modifications to the SetupCommand method.  Instead of the 
commandTimeout parameter, an Action<IDbCommand> could be passed to allow custom 
modifications to the commands.  This way people can do whatever they want to 
the command (including modifying timeouts).

Original issue reported on code.google.com by p...@paultyng.net on 19 Jan 2012 at 3:08

GoogleCodeExporter commented 8 years ago
So change SetupCommand to something like:

private static IDbCommand SetupCommand(IDbConnection cnn, IDbTransaction 
transaction, string sql, Action<IDbCommand, object> paramReader, object obj, 
Action<IDbCommand> commandCustomization, CommandType? commandType)

And the calls accordingly.  Can still provide overrides that allow for 
backwards compatibility.

Original comment by p...@paultyng.net on 19 Jan 2012 at 3:24

GoogleCodeExporter commented 8 years ago
[deleted comment]
GoogleCodeExporter commented 8 years ago
Was able to get around this using a custom DbConnection implementation that 
wrapped CreateCommand:

https://gist.github.com/1952498

Allows me to do global modifications to command objects, of course doesn't let 
me do granular control.

Original comment by p...@paultyng.net on 1 Mar 2012 at 7:36