コード例 #1
0
        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);
        }
コード例 #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);
        }
コード例 #3
0
ファイル: SqlExpTest.cs プロジェクト: Ropticus/Suilder
        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);
        }