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

            Exception ex = Assert.Throws <InvalidOperationException>(() => SqlExp.Le(person.Id, 1));

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

            QueryResult result = engine.Compile(op);

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

            QueryResult result = engine.Compile(op);

            Assert.Equal("\"person\".\"DepartmentId\" <= \"dept\".\"Id\"", result.Sql);
            Assert.Equal(new Dictionary <string, object>(), result.Parameters);
        }
Beispiel #4
0
        public void Expression_Method_List <T>(List <T> value)
        {
            Department dept = null;
            IOperator  op   = sql.Op(() => SqlExp.Le(dept.Tags, value));

            QueryResult result = engine.Compile(op);

            Assert.Equal("\"dept\".\"Tags\" <= @p0", result.Sql);
            Assert.Equal(new Dictionary <string, object>
            {
                ["@p0"] = value
            }, result.Parameters);
        }
Beispiel #5
0
        public void Expression_Method_Array_Inline_Value()
        {
            Person    person = null;
            IOperator op     = sql.Op(() => SqlExp.Le(person.Image, new byte[] { 1, 2, 3 }));

            QueryResult result = engine.Compile(op);

            Assert.Equal("\"person\".\"Image\" <= @p0", result.Sql);
            Assert.Equal(new Dictionary <string, object>
            {
                ["@p0"] = new byte[] { 1, 2, 3 }
            }, result.Parameters);
        }
Beispiel #6
0
        public void Expression_Method_Array <T>(T[] value)
        {
            Person    person = null;
            IOperator op     = sql.Op(() => SqlExp.Le(person.Image, value));

            QueryResult result = engine.Compile(op);

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

            QueryResult result = engine.Compile(op);

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

            QueryResult result = engine.Compile(op);

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

            QueryResult result = engine.Compile(op);

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

            QueryResult result = engine.Compile(op);

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