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);
        }
Exemplo n.º 2
0
        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);
        }
Exemplo n.º 3
0
        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);
        }