Example #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);
        }
Example #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);
        }
Example #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);
        }
Example #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);
        }
Example #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);
        }
Example #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);
        }