public void TestSimpleWhere() { var paramsCollection = new ParamsCollection(); var where = new WhereSequence("key", Is.EqualWith, "val", paramsCollection); Assert.AreEqual("key = @" + Math.Abs("val".GetHashCode()), where.ToString()); }
public void TestNull() { var collection = new ParamsCollection(); collection.GetIdentifier(null); Assert.AreEqual(0, collection.Params.Count); }
public void TestSimpleAndOr() { var paramsCollection = new ParamsCollection(); var where = new WhereSequence("a", Is.EqualWith, "b", paramsCollection).Or("c", Is.EqualWith, "d").And("e", Is.EqualWith, "f"); Assert.AreEqual(string.Format("a = @{0} OR c = @{1} AND e = @{2}", Math.Abs("b".GetHashCode()), Math.Abs("d".GetHashCode()), Math.Abs("f".GetHashCode())), where.ToString()); }
public void TestCollection() { var collection = new ParamsCollection(); Assert.AreEqual("@" + Math.Abs("test".GetHashCode()), collection.GetIdentifier("test")); Assert.AreEqual(1, collection.Params.Count); Assert.AreEqual("@" + Math.Abs("test".GetHashCode()), collection.Params.First().Key); Assert.AreEqual("test", collection.Params.First().Value); }
public void TestComplex() { var paramsCollection = new ParamsCollection(); var where = new WhereSequence("a", Is.EqualWith, "b", paramsCollection).And( subsequence => subsequence.Where("c", Is.EqualWith, "d").Or("e", Is.EqualWith, "f").Or( secondLevel => secondLevel.Where("g", Is.EqualWith, "h").And("i", Is.EqualWith, "j") ) ).Or("k", Is.EqualWith, "l"); Assert.AreEqual(string.Format("a = @{0} AND (c = @{1} OR e = @{2} OR (g = @{3} AND i = @{4})) OR k = @{5}", Math.Abs("b".GetHashCode()), Math.Abs("d".GetHashCode()), Math.Abs("f".GetHashCode()), Math.Abs("h".GetHashCode()), Math.Abs("j".GetHashCode()), Math.Abs("l".GetHashCode())), where.ToString()); }
public InsertBatch(IEnumerable <string> columns, IEnumerable <IConvertible> values, ParamsCollection paramsCollection) { var colArray = columns as string[] ?? columns.ToArray(); var valuesArray = values as IConvertible[] ?? values.ToArray(); if (colArray.Count() != valuesArray.Count()) { throw new InvalidOperationException("La ligne doit compter " + colArray.Count() + " colonnes"); } Sql = valuesArray.Aggregate("(", (current, value) => current + (paramsCollection.GetIdentifier(value) + ", ")).TrimEnd(' ', ',') + ")"; }
public WhereSequence(string key, IBinaryOperator binOperator, IConvertible value, ParamsCollection parentCollection) { _parentCollection = parentCollection; _sequence = binOperator.ToString(key, parentCollection.GetIdentifier(value)); }
internal SubSequence(ParamsCollection parentCollection) { _parentCollection = parentCollection; }
protected StatementAbstract(string tableName) { TableName = tableName; Params = new ParamsCollection(); }