Exemplo n.º 1
0
        public void Expression_Method_Invalid_Call()
        {
            Person person = new Person();

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

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

            QueryResult result = engine.Compile(op);

            Assert.Equal("\"person\".\"Name\" < NULL", result.Sql);
            Assert.Equal(new Dictionary <string, object>(), result.Parameters);
        }
Exemplo n.º 3
0
        public void Expression_Method_Column()
        {
            Person     person = null;
            Department dept   = null;
            IOperator  op     = sql.Op(() => SqlExp.Lt(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);
        }
Exemplo n.º 4
0
        public void Expression_Method()
        {
            Person    person = null;
            IOperator op     = sql.Op(() => SqlExp.Lt(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);
        }
Exemplo n.º 5
0
        public void Expression_Method_List <T>(List <T> value)
        {
            Department dept = null;
            IOperator  op   = sql.Op(() => SqlExp.Lt(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);
        }
Exemplo n.º 6
0
        public void Expression_Method_Array_Inline_Value()
        {
            Person    person = null;
            IOperator op     = sql.Op(() => SqlExp.Lt(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);
        }
Exemplo n.º 7
0
        public void Expression_Method_Array <T>(T[] value)
        {
            Person    person = null;
            IOperator op     = sql.Op(() => SqlExp.Lt(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);
        }
Exemplo n.º 8
0
        public void Expression_Method_Nested_Deep(object value)
        {
            Person2   person = null;
            IOperator op     = sql.Op(() => SqlExp.Lt(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);
        }
Exemplo n.º 9
0
        public void Expression_Method_ForeignKey(object value)
        {
            Person    person = null;
            IOperator op     = sql.Op(() => SqlExp.Lt(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);
        }
Exemplo n.º 10
0
        public void Expression_Method_List_Inline_Value()
        {
            Department dept = null;
            IOperator  op   = sql.Op(() => SqlExp.Lt(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);
        }