Created
June 20, 2011 18:15
-
-
Save einarwh/1036193 to your computer and use it in GitHub Desktop.
Dry data: Main execute method refactored.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public TResult Execute<T, TResult>(string spName, | |
Func<StoredProcedure, StoredProcedure> configure, | |
Func<IDbCommand, T> execute, | |
Func<T, TResult> map) | |
{ | |
using (var conn = _dpf.CreateConnection()) | |
using (var cmd = _dpf.CreateCommand()) | |
{ | |
conn.ConnectionString = _connStr; | |
conn.Open(); | |
cmd.Connection = conn; | |
cmd.CommandType = CommandType.StoredProcedure; | |
cmd.CommandText = spName; | |
configure(new StoredProcedure(cmd, _dpf)); | |
cmd.CommandType = CommandType.StoredProcedure; | |
return map(execute(cmd)); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment