public void Expression_Method_Invalid_Call() { Person person = new Person(); Exception ex = Assert.Throws <InvalidOperationException>(() => SqlExp.Ge(person.Id, 1)); Assert.Equal("Only for expressions.", ex.Message); }
public void Expression_Method_Null() { Person person = null; IOperator op = sql.Op(() => SqlExp.Ge(person.Name, null)); QueryResult result = engine.Compile(op); Assert.Equal("\"person\".\"Name\" >= NULL", result.Sql); Assert.Equal(new Dictionary <string, object>(), result.Parameters); }
public void Expression_Method_Column() { Person person = null; Department dept = null; IOperator op = sql.Op(() => SqlExp.Ge(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); }
public void Expression_Method() { Person person = null; IOperator op = sql.Op(() => SqlExp.Ge(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); }
public void Expression_Method_List <T>(List <T> value) { Department dept = null; IOperator op = sql.Op(() => SqlExp.Ge(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); }
public void Expression_Method_Array_Inline_Value() { Person person = null; IOperator op = sql.Op(() => SqlExp.Ge(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); }
public void Expression_Method_Array <T>(T[] value) { Person person = null; IOperator op = sql.Op(() => SqlExp.Ge(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); }
public void Expression_Method_Nested_Deep(object value) { Person2 person = null; IOperator op = sql.Op(() => SqlExp.Ge(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); }
public void Expression_Method_ForeignKey(object value) { Person person = null; IOperator op = sql.Op(() => SqlExp.Ge(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); }
public void Expression_Method_List_Inline_Value() { Department dept = null; IOperator op = sql.Op(() => SqlExp.Ge(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); }