Beispiel #1
0
 private static string GetCharacteristicQuery(IFilter characteristic, SqlParameterCollection parameterCollection)
 {
     SqlParameter[] parameters = characteristic.MakeQuery();
     parameterCollection.AddRange(parameters);
     return
         ($"{characteristic.Title} >= {parameters[0].ParameterName} AND {characteristic.Title} <= {parameters[1].ParameterName}");
 }
        public void CollectionAddInvalidRange_Throws()
        {
            SqlCommand             command    = new SqlCommand();
            SqlParameterCollection collection = command.Parameters;

            Array invalid = null;

            Assert.Throws <ArgumentNullException>(() => collection.AddRange(invalid));
        }
        public void CollectionAddRange()
        {
            SqlCommand             command    = new SqlCommand();
            SqlParameterCollection collection = command.Parameters;
            Array sqlParameters = new SqlParameter[] { new("Test1", 1), new("Test2", 2) };

            collection.AddRange(sqlParameters);

            Assert.Equal(2, collection.Count);
            Assert.Equal((SqlParameter)sqlParameters.GetValue(0), collection[0]);
            Assert.Equal((SqlParameter)sqlParameters.GetValue(1), collection[1]);
        }
Beispiel #4
0
 public void AddOtherFilter(string sql, params SqlParameter[] list)
 {
     if (whereStringAdded == false)
     {
         sb.Append(" where ");
         whereStringAdded = true;
         filterAdded++;
     }
     else
     {
         sb.Append(" and ");
     }
     sb.Append(sql);
     if (list != null)
     {
         parameterList.AddRange(list);
     }
 }
    public static SqlParameterCollection AddParameters(this SqlParameterCollection parameters, params SqlParameter[] args)
    {
        parameters.AddRange(args);

        return(parameters);
    }