public void Substring() { Person person = new Person(); Exception ex = Assert.Throws <InvalidOperationException>(() => SqlExp.Substring(person.Name, 2, 4)); Assert.Equal("Only for expressions.", ex.Message); }
public void Substring() { Person person = null; IFunction func = (IFunction)sql.Val(() => SqlExp.Substring(person.Name, 2, 4)); QueryResult result = engine.Compile(func); Assert.Equal("SUBSTRING(`person`.`Name`, @p0, @p1)", result.Sql); Assert.Equal(new Dictionary <string, object>() { ["@p0"] = 2, ["@p1"] = 4 }, result.Parameters); }
public void Substring() { Person person = null; IFunction func = (IFunction)sql.Val(() => SqlExp.Substring(person.Name, 2, 4)); QueryResult result = engine.Compile(func); Assert.Equal("SUBSTR(\"PERSON\".\"NAME\", :p0, :p1)", result.Sql); Assert.Equal(new Dictionary <string, object> { [":p0"] = 2, [":p1"] = 4 }, result.Parameters); }