public void NullIf()
        {
            Person person = new Person();

            Exception ex = Assert.Throws <InvalidOperationException>(() => SqlExp.NullIf(person.Name, "empty"));

            Assert.Equal("Only for expressions.", ex.Message);
        }
Beispiel #2
0
        public void NullIf()
        {
            Person    person = null;
            IFunction func   = (IFunction)sql.Val(() => SqlExp.NullIf(person.Name, "empty"));

            QueryResult result = engine.Compile(func);

            Assert.Equal("NULLIF(`person`.`Name`, @p0)", result.Sql);
            Assert.Equal(new Dictionary <string, object>()
            {
                ["@p0"] = "empty"
            }, result.Parameters);
        }