Esempio n. 1
0
        protected override Expression VisitSource(Expression source)
        {
            switch ((DbExpressionType)source.NodeType)
            {
            case DbExpressionType.Table:
                TableExpression table = (TableExpression)source;
                _sb.Append('[')
                .Append(table.Name)
                .Append(']');
                if (!string.IsNullOrWhiteSpace(table.Alias))
                {
                    _sb.Append(" AS ").Append(table.Alias);
                }
                break;

            case DbExpressionType.RawQuery:
                RawQueryExpression rawQuery = (RawQueryExpression)source;
                _sb.Append("(")
                .Append(rawQuery.SQLQuery)
                .Append(")");
                if (!string.IsNullOrWhiteSpace(rawQuery.Alias))
                {
                    _sb.Append(" AS ").Append(rawQuery.Alias);
                }
                break;

            case DbExpressionType.Select:
                SelectExpression select = (SelectExpression)source;
                _sb.Append("(");
                AppendNewLine(Indentation.Inner);
                Visit(select);
                AppendNewLine(Indentation.Outer);
                _sb.Append(")");
                if (!string.IsNullOrWhiteSpace(select.Alias))
                {
                    _sb.Append(" AS ").Append(select.Alias);
                }
                break;

            case DbExpressionType.Join:
                VisitJoin((JoinExpression)source);
                break;

            default:
                throw new InvalidOperationException("Select source is not valid type");
            }
            return(source);
        }
Esempio n. 2
0
 protected virtual Expression VisitRawQuery(RawQueryExpression rawQuery)
 {
     return(rawQuery);
 }
Esempio n. 3
0
 protected override Expression VisitRawQuery(RawQueryExpression rawQuery)
 {
     _sb.Append(rawQuery.SQLQuery);
     return(rawQuery);
 }