public void Val() { Person person = new Person(); Exception ex = Assert.Throws <InvalidOperationException>(() => SqlExp.Val(person.Id)); Assert.Equal("Only for expressions.", ex.Message); }
public object Coalesce_Operator_Value() { Person person = new Person() { Name = null }; return(sql.Val(() => SqlExp.Val(person.Name ?? "abcd"))); }
public object Conditional_Operator_Value() { Person person = new Person() { Name = null, SurName = "efgh" }; return(sql.Val(() => SqlExp.Val(person.Name != null ? person.SurName : "abcd"))); }
public object Bit_Operator_Value() { Person person = new Person() { Id = 1 }; return(sql.Val(() => SqlExp.Val(person.Id & 2))); }
public object Arith_Operator_Value_Overload() { Person person = new Person() { Salary = 1000 }; return(sql.Val(() => SqlExp.Val(person.Salary + 200m))); }
public object Comparison_Operator_Value() { Person person = new Person() { Id = 1 }; return(sql.Val(() => SqlExp.Val(person.Id == 1))); }
public void Alias_Value() { Person person = new Person() { Id = 1 }; Assert.Equal(person.Id, sql.Val(() => SqlExp.Val(person.Id))); }
public void Not_Operator(bool value) { Person person = new Person() { Active = value }; Assert.Equal(!person.Active, sql.Val(() => SqlExp.Val(!person.Active))); }
public object Alias_Value() { Person person = new Person() { Id = 1 }; return(sql.Val(() => SqlExp.Val(person.Id))); }
public void Coalesce_Operator_Value(string name, string value) { Person person = new Person() { Name = name }; Assert.Equal(person.Name ?? value, sql.Val(() => SqlExp.Val(person.Name ?? value))); }
public void Modulo_Operator_Value_Overload_Convert(int value) { Person person = new Person() { Salary = 1000 }; Assert.Equal(person.Salary % value, sql.Val(() => SqlExp.Val(person.Salary % value))); }
public void BitXor_Operator_Value(int value) { Person person = new Person() { Id = 1 }; Assert.Equal(person.Id ^ value, sql.Val(() => SqlExp.Val(person.Id ^ value))); }
public void Divide_Operator_Value_Overload(decimal value) { Person person = new Person() { Salary = 1000 }; Assert.Equal(person.Salary / value, sql.Val(() => SqlExp.Val(person.Salary / value))); }
public void Add_Operator_Value_String(string value) { Person person = new Person() { Name = "abcd" }; Assert.Equal(person.Name + value, sql.Val(() => SqlExp.Val(person.Name + value))); }
public void Conditional_Operator_Value(string name, string value) { Person person = new Person() { Name = name, SurName = name }; Assert.Equal(person.Name != null ? person.SurName : value, sql.Val(() => SqlExp.Val(person.Name != null ? person.SurName : value))); }
public void OrElse_Operator_Value(int id, string name) { Person person = new Person() { Id = 1, Name = "abcd" }; Assert.Equal(person.Id == id || person.Name == name, sql.Val(() => SqlExp.Val(person.Id == id || person.Name == name))); }
public object Nested_Alias_Value() { Person person = new Person() { Department = new Department() { Id = 1 } }; return(sql.Val(() => SqlExp.Val(person.Department.Id))); }
public void Nested_Alias_Value() { Person person = new Person() { Department = new Department() { Id = 1 } }; Assert.Equal(person.Department.Id, sql.Val(() => SqlExp.Val(person.Department.Id))); }
public void Val_Method() { Person person = null; Person personValue = new Person() { Name = "abcd" }; IOperator op = (IOperator)sql.Op(() => person.Active == SqlExp.Val(personValue.Name.Contains("bc"))); QueryResult result = engine.Compile(op); Assert.Equal("\"person\".\"Active\" = @p0", result.Sql); Assert.Equal(new Dictionary <string, object> { ["@p0"] = personValue.Name.Contains("bc") }, result.Parameters); }
public void Val_Alias() { Person person = null; Person personValue = new Person() { Id = 1 }; IOperator op = (IOperator)sql.Op(() => person.Id == SqlExp.Val(personValue.Id)); QueryResult result = engine.Compile(op); Assert.Equal("\"person\".\"Id\" = @p0", result.Sql); Assert.Equal(new Dictionary <string, object> { ["@p0"] = personValue.Id }, result.Parameters); }