Skip to content

Instantly share code, notes, and snippets.

@asmorger
Created August 25, 2025 21:10
Show Gist options
  • Select an option

  • Save asmorger/44f8b7e9f043ffb89ff8e6c9f298b49c to your computer and use it in GitHub Desktop.

Select an option

Save asmorger/44f8b7e9f043ffb89ff8e6c9f298b49c to your computer and use it in GitHub Desktop.
public interface ISqlCommandFactory
{
SqlCommand GetCommand(SqlConnection connection, string storedProcedure,
SqlParameter[]? parameters = null);
}
public class SqlCommandFactory : ISqlCommandFactory
{
public SqlCommand GetCommand(SqlConnection connection, string storedProcedure,
SqlParameter[]? parameters = null)
{
var command = new SqlCommand(storedProcedure, connection) { CommandType = CommandType.StoredProcedure };
if(parameters != null)
command.Parameters.AddRange(parameters);
return command;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment