/// <summary> /// A convenience method for adding a string with size and value. /// </summary> public static SqlParameter AddString ( this SqlParameterCollection parameters, string parameterName, int size, string value ) { parameters.ThrowIfNull("parameters"); parameterName.ThrowIfNullOrEmpty("parameterName"); var p = new SqlParameter(parameterName, SqlDbType.VarChar, size); p.SetValue(value); parameters.Add(p); return(p); }
public static SqlParameter AddOutputId ( this SqlParameterCollection parameters, string parameterName = "Id", SqlDbType parameterType = SqlDbType.Int ) { parameters.ThrowIfNull("parameters"); parameterName.ThrowIfNullOrEmpty("parameterName"); var p = new SqlParameter(); p.ParameterName = parameterName; p.Direction = ParameterDirection.Output; p.SqlDbType = parameterType; parameters.Add(p); return(p); }
public static SqlParameter AddWithNullableValue <T> ( this SqlParameterCollection parameters, string parameterName, T?value ) where T : struct { parameters.ThrowIfNull("parameters"); parameterName.ThrowIfNullOrEmpty("parameterName"); var p = new SqlParameter(); p.ParameterName = parameterName; p.SetValue(value); parameters.Add(p); return(p); }