Beispiel #1
0
        public virtual SqlFragment BuildSqlForSqlFunctionExpression(SqlFunctionExpression expr)
        {
            SqlTemplate template = SqlDialect.GetSqlFunctionTemplate(expr);

            if (template != null)
            {
                var args    = expr.GetOperands();
                var sqlArgs = args.Select(a => BuildLinqExpressionSql(a)).ToArray();
                return(template.Format(sqlArgs));
            }
            return(BuildSqlForSqlFunctionExpressionNoTemplate(expr));
        }//class
Beispiel #2
0
        }//class

        public virtual SqlFragment BuildSqlForSqlFunctionExpressionNoTemplate(SqlFunctionExpression expr)
        {
            //concat - special case; turn all args into comma-delimited list
            if (expr.FunctionType == SqlFunctionType.Concat)
            {
                var args     = expr.GetOperands();
                var sqlArgs  = args.Select(a => BuildLinqExpressionSql(a)).ToList();
                var argsPart = SqlFragment.CreateList(SqlDialect.SqlConcatListDelimiter, sqlArgs);
                return(SqlDialect.SqlTemplateConcatMany.Format(argsPart));
            }
            Util.Throw("Unsupported SqlFunction type: {0}, expr: {1} ", expr.FunctionType, expr);
            return(null);
        }