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

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

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

            QueryResult result = engine.Compile(op);

            Assert.Equal("NOT \"person\".\"DepartmentId\" = \"dept\".\"Id\"", result.Sql);
            Assert.Equal(new Dictionary <string, object>(), result.Parameters);
        }
示例#3
0
        public void Expression_Method_Bool_Property()
        {
            Person    person = null;
            IOperator op     = sql.Op(() => SqlExp.Not(person.Active));

            QueryResult result = engine.Compile(op);

            Assert.Equal("NOT \"person\".\"Active\" = @p0", result.Sql);
            Assert.Equal(new Dictionary <string, object>
            {
                ["@p0"] = true
            }, result.Parameters);
        }
示例#4
0
        public void Expression_Method_Nested_Deep(string value)
        {
            Person2   person = null;
            IOperator op     = sql.Op(() => SqlExp.Not(person.Address.City.Country.Name == value));

            QueryResult result = engine.Compile(op);

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

            QueryResult result = engine.Compile(op);

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

            QueryResult result = engine.Compile(op);

            Assert.Equal("NOT \"person\".\"Id\" = @p0", result.Sql);
            Assert.Equal(new Dictionary <string, object>
            {
                ["@p0"] = 1
            }, result.Parameters);
        }