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

            Exception ex = Assert.Throws <InvalidOperationException>(() => SqlExp.NotLike(person.Name, "%abcd%"));

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

            QueryResult result = engine.Compile(op);

            Assert.Equal("\"person\".\"Name\" NOT LIKE NULL", result.Sql);
            Assert.Equal(new Dictionary <string, object>(), result.Parameters);
        }
示例#3
0
        public void Expression_Method_Column()
        {
            Person2     person = null;
            Department2 dept   = null;
            IOperator   op     = sql.Op(() => SqlExp.NotLike(person.Department.Guid, dept.Guid));

            QueryResult result = engine.Compile(op);

            Assert.Equal("\"person\".\"DepartmentGuid\" NOT LIKE \"dept\".\"Guid\"", result.Sql);
            Assert.Equal(new Dictionary <string, object>(), result.Parameters);
        }
示例#4
0
        public void Expression_Method_List <T>(List <T> value)
        {
            Department dept = null;
            IOperator  op   = sql.Op(() => SqlExp.NotLike(dept.Tags, value));

            QueryResult result = engine.Compile(op);

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

            QueryResult result = engine.Compile(op);

            Assert.Equal("\"person\".\"Image\" NOT LIKE @p0", result.Sql);
            Assert.Equal(new Dictionary <string, object>
            {
                ["@p0"] = new byte[] { 1, 2, 3 }
            }, result.Parameters);
        }
示例#6
0
        public void Expression_Method_Nested_Deep(object value)
        {
            Person2   person = null;
            IOperator op     = sql.Op(() => SqlExp.NotLike(person.Address.City.Country.Name, value));

            QueryResult result = engine.Compile(op);

            Assert.Equal("\"person\".\"AddressCityCountryName\" NOT LIKE @p0", result.Sql);
            Assert.Equal(new Dictionary <string, object>
            {
                ["@p0"] = value
            }, result.Parameters);
        }
示例#7
0
        public void Expression_Method_ForeignKey(object value)
        {
            Person2   person = null;
            IOperator op     = sql.Op(() => SqlExp.NotLike(person.Department.Guid, value));

            QueryResult result = engine.Compile(op);

            Assert.Equal("\"person\".\"DepartmentGuid\" NOT LIKE @p0", result.Sql);
            Assert.Equal(new Dictionary <string, object>
            {
                ["@p0"] = value
            }, result.Parameters);
        }
示例#8
0
        public void Expression_Method_Inline_Value()
        {
            Person    person = null;
            IOperator op     = sql.Op(() => SqlExp.NotLike(person.Name, "%abcd%"));

            QueryResult result = engine.Compile(op);

            Assert.Equal("\"person\".\"Name\" NOT LIKE @p0", result.Sql);
            Assert.Equal(new Dictionary <string, object>
            {
                ["@p0"] = "%abcd%"
            }, result.Parameters);
        }
示例#9
0
        public void Expression_Method_List_Inline_Value()
        {
            Department dept = null;
            IOperator  op   = sql.Op(() => SqlExp.NotLike(dept.Tags, new List <string> {
                "abcd", "efgh", "ijkl"
            }));

            QueryResult result = engine.Compile(op);

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