Example #1
0
        public void Expression_Method_Invalid_Call()
        {
            Person person = new Person();

            Exception ex = Assert.Throws <InvalidOperationException>(() => SqlExp.In(person.Id, new int[] { 1, 2, 3 }));

            Assert.Equal("Only for expressions.", ex.Message);
        }
Example #2
0
        public void Expression_Method_Null()
        {
            Person    person = null;
            IOperator op     = sql.Op(() => SqlExp.In(person.Name, null));

            QueryResult result = engine.Compile(op);

            Assert.Equal("\"person\".\"Name\" IN NULL", result.Sql);
            Assert.Equal(new Dictionary <string, object>(), result.Parameters);
        }
Example #3
0
        public void Expression_Method_Column()
        {
            Person     person = null;
            Department dept   = null;
            IOperator  op     = sql.Op(() => SqlExp.In(person.Department.Id, dept.Id));

            QueryResult result = engine.Compile(op);

            Assert.Equal("\"person\".\"DepartmentId\" IN \"dept\".\"Id\"", result.Sql);
            Assert.Equal(new Dictionary <string, object>(), result.Parameters);
        }
Example #4
0
        public void Expression_Method()
        {
            Person    person = null;
            IOperator op     = sql.Op(() => SqlExp.In(person.Id, 1));

            QueryResult result = engine.Compile(op);

            Assert.Equal("\"person\".\"Id\" IN @p0", result.Sql);
            Assert.Equal(new Dictionary <string, object>
            {
                ["@p0"] = 1
            }, result.Parameters);
        }
Example #5
0
        public void Expression_Method_Nested_Deep(object value)
        {
            Person2   person = null;
            IOperator op     = sql.Op(() => SqlExp.In(person.Address.City.Country.Name, value));

            QueryResult result = engine.Compile(op);

            Assert.Equal("\"person\".\"AddressCityCountryName\" IN @p0", result.Sql);
            Assert.Equal(new Dictionary <string, object>
            {
                ["@p0"] = value
            }, result.Parameters);
        }
Example #6
0
        public void Expression_Method_ForeignKey(object value)
        {
            Person    person = null;
            IOperator op     = sql.Op(() => SqlExp.In(person.Department.Id, value));

            QueryResult result = engine.Compile(op);

            Assert.Equal("\"person\".\"DepartmentId\" IN @p0", result.Sql);
            Assert.Equal(new Dictionary <string, object>
            {
                ["@p0"] = value
            }, result.Parameters);
        }
Example #7
0
        public void Expression_Method()
        {
            Person    person = null;
            IOperator op     = sql.Op(() => SqlExp.In(person.Id, new int[] { 1, 2, 3 }));

            QueryResult result = engine.Compile(op);

            Assert.Equal("\"person\".\"Id\" IN (@p0, @p1, @p2)", result.Sql);
            Assert.Equal(new Dictionary <string, object>()
            {
                ["@p0"] = 1, ["@p1"] = 2, ["@p2"] = 3
            }, result.Parameters);
        }
Example #8
0
        public void Expression_Method_List <T>(List <T> value)
        {
            Department dept = null;
            IOperator  op   = sql.Op(() => SqlExp.In(dept.Name, value));

            QueryResult result = engine.Compile(op);

            Assert.Equal("\"dept\".\"Name\" IN (@p0, @p1, @p2)", result.Sql);
            Assert.Equal(new Dictionary <string, object>
            {
                ["@p0"] = value[0],
                ["@p1"] = value[1],
                ["@p2"] = value[2]
            }, result.Parameters);
        }
Example #9
0
        public void Expression_Method_Array <T>(T[] value)
        {
            Person    person = null;
            IOperator op     = sql.Op(() => SqlExp.In(person.Id, value));

            QueryResult result = engine.Compile(op);

            Assert.Equal("\"person\".\"Id\" IN (@p0, @p1, @p2)", result.Sql);
            Assert.Equal(new Dictionary <string, object>
            {
                ["@p0"] = value[0],
                ["@p1"] = value[1],
                ["@p2"] = value[2]
            }, result.Parameters);
        }
Example #10
0
        public void Expression_Method_List_Inline_Value()
        {
            Department dept = null;
            IOperator  op   = sql.Op(() => SqlExp.In(dept.Name, new List <string> {
                "abcd", "efgh", "ijkl"
            }));

            QueryResult result = engine.Compile(op);

            Assert.Equal("\"dept\".\"Name\" IN (@p0, @p1, @p2)", result.Sql);
            Assert.Equal(new Dictionary <string, object>
            {
                ["@p0"] = "abcd",
                ["@p1"] = "efgh",
                ["@p2"] = "ijkl"
            }, result.Parameters);
        }