Inheritance: System.Linq.Expressions.Expression
Ejemplo n.º 1
0
 public static Expression Parse(LambdaExpression expression, Expression keyExpr, InjectedExpression subquery, Func<Expression, TranslateResult> translator)
 {
     AggregateParser parser = new AggregateParser();
     parser.map = expression.Parameters.Select((param, i) => new { param, i })
         .ToDictionary(x => x.param, x => x.i == 0 ? keyExpr : subquery);
     parser.translator = translator;
     return parser.Visit(expression.Body);
 }
Ejemplo n.º 2
0
 protected override Expression VisitInjected(InjectedExpression node)
 {
     SqlExpression sqlExpr = node.TranslateResult.SqlExpression;
     if (sqlExpr.NodeType == SqlExpressionType.Column)
     {
         ColumnExpression column = (ColumnExpression)sqlExpr;
         ColumnExpression mapped;
         if (this.map.TryGetValue(column, out mapped))
         {
             return new InjectedExpression(new TranslateResult(mapped), node.Type);
         }
         foreach (ColumnDeclaration existingColumn in this.columns)
         {
             ColumnExpression c = existingColumn.Expression as ColumnExpression;
             if (c != null && c.TableAlias == column.TableAlias && c.ColumnName == column.ColumnName)
             {
                 return new InjectedExpression(new TranslateResult(new ColumnExpression(this.newAlias, existingColumn.DeclaredName)), node.Type);
             }
         }
         if (this.existingAliases.Contains(column.TableAlias))
         {
             string declaredName = this.GetUniqueColumnName(column.ColumnName);
             this.columns.Add(new ColumnDeclaration(declaredName, column));
             mapped = new ColumnExpression(this.newAlias, declaredName);
             this.map.Add(column, mapped);
             return new InjectedExpression(new TranslateResult(mapped), node.Type);
         }
         return node;
     }
     else
     {
         string declaredName = this.GetNextColumnName();
         this.columns.Add(new ColumnDeclaration(declaredName, sqlExpr));
         return new InjectedExpression(new TranslateResult(new ColumnExpression(this.newAlias, declaredName)), node.Type);
     }
 }
Ejemplo n.º 3
0
 protected virtual Expression VisitInjected(InjectedExpression node)
 {
     return node;
 }