Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Dry data: Main execute method refactored.
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