Esempio n. 1
0
        public void DynamicSQLinq_Oracle_Test_004_B()
        {
            var dialect = new SQLinq.OracleDialect();

            var where = new DynamicSQLinqExpressionCollection(dialect, DynamicSQLinqWhereOperator.Or);
            where.Add("Make = @0", "Ford")
            .Add("Color = @0 OR Color = @1", 0, 1);

            var where2 = new DynamicSQLinqExpressionCollection(dialect);

            where2.Add("Make = @0", "Chevrolet");

            where.Add(where2);

            var query = new DynamicSQLinq("Car")
                        .Where(where);

            var sql = query.ToSQL();

            var code = sql.ToQuery();

            Assert.AreEqual("SELECT * FROM Car WHERE (Make = :sqlinq_1) OR (Color = :sqlinq_2 OR Color = :sqlinq_3) OR (Make = :sqlinq_4)", code);

            Assert.AreEqual("Ford", sql.Parameters[":sqlinq_1"]);
            Assert.AreEqual(0, sql.Parameters[":sqlinq_2"]);
            Assert.AreEqual(1, sql.Parameters[":sqlinq_3"]);
            Assert.AreEqual("Chevrolet", sql.Parameters[":sqlinq_4"]);
        }
Esempio n. 2
0
        public void DynamicSQLinq_Test_006()
        {
            var where = new DynamicSQLinqExpressionCollection(DynamicSQLinqWhereOperator.Or);
            where.Add("(Make = @0) OR (Make <> @0 AND Color = @1)", "Ford", 15)
            .Add("Color = @0 OR Color = @1", 0, 1);

            var where2 = new DynamicSQLinqExpressionCollection();

            where2.Add("Make = @0", "Chevrolet");

            where.Add(where2);

            var query = new DynamicSQLinq("Car")
                        .Where(where);

            var sql = query.ToSQL();

            var code = sql.ToQuery();

            Assert.AreEqual("SELECT * FROM Car WHERE ((Make = @sqlinq_1) OR (Make <> @sqlinq_1 AND Color = @sqlinq_2)) OR (Color = @sqlinq_3 OR Color = @sqlinq_4) OR (Make = @sqlinq_5)", code);

            Assert.AreEqual("Ford", sql.Parameters["@sqlinq_1"]);
            Assert.AreEqual(15, sql.Parameters["@sqlinq_2"]);
            Assert.AreEqual(0, sql.Parameters["@sqlinq_3"]);
            Assert.AreEqual(1, sql.Parameters["@sqlinq_4"]);
            Assert.AreEqual("Chevrolet", sql.Parameters["@sqlinq_5"]);
        }
Esempio n. 3
0
        public void DynamicSQLinq_Test_Count_004()
        {
            var where = new DynamicSQLinqExpressionCollection(DynamicSQLinqWhereOperator.Or);
            where.Add("Make = @0", "Ford")
            .Add("Color = @0 OR Color = @1", 0, 1);

            var where2 = new DynamicSQLinqExpressionCollection();

            where2.Add("Make = @0", "Chevrolet");

            where.Add(where2);

            var query = new DynamicSQLinq("Car")
                        .Where(where)
                        .Count();

            var sql = query.ToSQL();

            var code = sql.ToQuery();

            Assert.AreEqual("SELECT COUNT(1) FROM Car WHERE (Make = @sqlinq_1) OR (Color = @sqlinq_2 OR Color = @sqlinq_3) OR (Make = @sqlinq_4)", code);

            Assert.AreEqual("Ford", sql.Parameters["@sqlinq_1"]);
            Assert.AreEqual(0, sql.Parameters["@sqlinq_2"]);
            Assert.AreEqual(1, sql.Parameters["@sqlinq_3"]);
            Assert.AreEqual("Chevrolet", sql.Parameters["@sqlinq_4"]);
        }
Esempio n. 4
0
        public void DynamicSQLinq_Test_002()
        {
            var where = new DynamicSQLinqExpressionCollection();
            where.Add("Make = @0", "Ford")
            .Add("Color = @0 OR Color = @1", 0, 1);

            var query = new DynamicSQLinq("Car")
                        .Where(where);

            var sql = query.ToSQL();

            var code = sql.ToQuery();

            Assert.AreEqual("SELECT * FROM Car WHERE (Make = @sqlinq_1) AND (Color = @sqlinq_2 OR Color = @sqlinq_3)", code);

            Assert.AreEqual("Ford", sql.Parameters["@sqlinq_1"]);
            Assert.AreEqual(0, sql.Parameters["@sqlinq_2"]);
            Assert.AreEqual(1, sql.Parameters["@sqlinq_3"]);
        }
Esempio n. 5
0
        public void DynamicSQLinq_Test_002()
        {
            var where = new DynamicSQLinqExpressionCollection();
            where.Add("Make = @0", "Ford")
                 .Add("Color = @0 OR Color = @1", 0, 1);

            var query = new DynamicSQLinq("Car")
                            .Where(where);

            var sql = query.ToSQL();

            var code = sql.ToQuery();

            Assert.AreEqual("SELECT * FROM Car WHERE (Make = @sqlinq_1) AND (Color = @sqlinq_2 OR Color = @sqlinq_3)", code);

            Assert.AreEqual("Ford", sql.Parameters["@sqlinq_1"]);
            Assert.AreEqual(0, sql.Parameters["@sqlinq_2"]);
            Assert.AreEqual(1, sql.Parameters["@sqlinq_3"]);
        }
Esempio n. 6
0
        public void DynamicSQLinq_Test_006()
        {
            var where = new DynamicSQLinqExpressionCollection(DynamicSQLinqWhereOperator.Or);
            where.Add("(Make = @0) OR (Make <> @0 AND Color = @1)", "Ford", 15)
                 .Add("Color = @0 OR Color = @1", 0, 1);

            var where2 = new DynamicSQLinqExpressionCollection();
            where2.Add("Make = @0", "Chevrolet");

            where.Add(where2);

            var query = new DynamicSQLinq("Car")
                            .Where(where);

            var sql = query.ToSQL();

            var code = sql.ToQuery();

            Assert.AreEqual("SELECT * FROM Car WHERE ((Make = @sqlinq_1) OR (Make <> @sqlinq_1 AND Color = @sqlinq_2)) OR (Color = @sqlinq_3 OR Color = @sqlinq_4) OR (Make = @sqlinq_5)", code);

            Assert.AreEqual("Ford", sql.Parameters["@sqlinq_1"]);
            Assert.AreEqual(15, sql.Parameters["@sqlinq_2"]);
            Assert.AreEqual(0, sql.Parameters["@sqlinq_3"]);
            Assert.AreEqual(1, sql.Parameters["@sqlinq_4"]);
            Assert.AreEqual("Chevrolet", sql.Parameters["@sqlinq_5"]);
        }
Esempio n. 7
0
        public void DynamicSQLinq_Oracle_Test_004_B()
        {
            var dialect = new SQLinq.OracleDialect();
            var where = new DynamicSQLinqExpressionCollection(dialect, DynamicSQLinqWhereOperator.Or);
            where.Add("Make = @0", "Ford")
                 .Add("Color = @0 OR Color = @1", 0, 1);

            var where2 = new DynamicSQLinqExpressionCollection(dialect);
            where2.Add("Make = @0", "Chevrolet");

            where.Add(where2);

            var query = new DynamicSQLinq("Car")
                            .Where(where);

            var sql = query.ToSQL();

            var code = sql.ToQuery();

            Assert.AreEqual("SELECT * FROM Car WHERE (Make = :sqlinq_1) OR (Color = :sqlinq_2 OR Color = :sqlinq_3) OR (Make = :sqlinq_4)", code);

            Assert.AreEqual("Ford", sql.Parameters[":sqlinq_1"]);
            Assert.AreEqual(0, sql.Parameters[":sqlinq_2"]);
            Assert.AreEqual(1, sql.Parameters[":sqlinq_3"]);
            Assert.AreEqual("Chevrolet", sql.Parameters[":sqlinq_4"]);
        }
Esempio n. 8
0
        public void DynamicSQLinq_Test_Count_004()
        {
            var where = new DynamicSQLinqExpressionCollection(DynamicSQLinqWhereOperator.Or);
            where.Add("Make = @0", "Ford")
                 .Add("Color = @0 OR Color = @1", 0, 1);

            var where2 = new DynamicSQLinqExpressionCollection();
            where2.Add("Make = @0", "Chevrolet");

            where.Add(where2);

            var query = new DynamicSQLinq("Car")
                            .Where(where)
                            .Count();

            var sql = query.ToSQL();

            var code = sql.ToQuery();

            Assert.AreEqual("SELECT COUNT(1) FROM Car WHERE (Make = @sqlinq_1) OR (Color = @sqlinq_2 OR Color = @sqlinq_3) OR (Make = @sqlinq_4)", code);

            Assert.AreEqual("Ford", sql.Parameters["@sqlinq_1"]);
            Assert.AreEqual(0, sql.Parameters["@sqlinq_2"]);
            Assert.AreEqual(1, sql.Parameters["@sqlinq_3"]);
            Assert.AreEqual("Chevrolet", sql.Parameters["@sqlinq_4"]);
        }