public static void ExecuteNonQuery(this IDatabaseAccessor instance, string commandText, dynamic parameterValues) { using (SqlConnection connection = instance.CreateConnection()) { string outputValue = null; connection.Open(); SqlCommand command = instance.CreateCommand(connection, commandText, CommandType.StoredProcedure); IEnumerable <PropertyInfo> properties = ((Type)parameterValues.GetType()).GetProperties().Where(property => property.CanRead); properties.ForEach(property => { object value = property.GetValue(parameterValues, null); SqlDbType?valType = null; ParameterDirection direction = ParameterDirection.Input; string parameterName = property.Name; if (parameterName.StartsWith("_")) { direction = ParameterDirection.InputOutput; parameterName = parameterName.Substring(1); outputValue = parameterName; } if (!parameterName.Equals("IncludeDeleted", StringComparison.OrdinalIgnoreCase)) { command.SetParameter(parameterName, value, direction, valType); } else { command.SetIncludeDeletedParameter((bool)value); } }); var reader = command.ExecuteNonQuery(); } }