Created
June 20, 2011 18:03
-
-
Save einarwh/1036141 to your computer and use it in GitHub Desktop.
Dry data: Main execute method
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, | |
DbParameter[] sqlParams, 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; | |
cmd.Parameters.AddRange(sqlParams); | |
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