Exemple #1
0
        public void TestSqlLike()
        {
            var expression = DbFluent.Like(
                DbFluent.Table("MyTable"),
                DbFluent.Concat("%", DbFluent.Parameter("myText").AsExp(), "%"));
            var log = new BdoLog();

            string expectedResult = @"$sqlLike($sqlTable('MyTable'), $sqlConcat($sqlText('%'), $sqlParameter('myText'), $sqlText('%')))";

            string result = (string)expression;

            string xml = "";

            if (log.HasErrorsOrExceptions())
            {
                xml = ". Result was '" + log.ToXml();
            }
            Assert.That(result.Trim().Equals(expectedResult.Trim(), StringComparison.OrdinalIgnoreCase), "Bad script interpretation" + xml);

            // scripted

            result = _appHost.Interpreter.Evaluate <string>(
                expression,
                new ScriptVariableSet().SetDbBuilder(new DbQueryBuilder_PostgreSql()),
                log: log);
            expectedResult = @"(""MyTable"" like concat('%', |*|p:myText|*|, '%'))";
            xml            = "";
            if (log.HasErrorsOrExceptions())
            {
                xml = ". Result was '" + log.ToXml();
            }
            Assert.That(result.Trim().Equals(expectedResult.Trim(), StringComparison.OrdinalIgnoreCase), "Bad script interpretation" + xml);
        }