protected virtual Expression VisitFrom(FromExpression from) { this.Write(".From("); this.WriteLine(Indentation.Inner); this.Visit(from.From); this.WriteLine(Indentation.Outer); this.Write(")"); return from; }
internal SelectExpression(LambdaExpression projection, FromExpression from, WhereExpression where, string alias, bool isProjection, Expression take, OrderByClause orderBy) : base(CompleteExpressionType.Select, typeof(IEnumerable<>).MakeGenericType(projection.ReturnType)) { this.Projection = projection; this.Alias = alias; this.From = from; this.Where = where; this.Take = take; this.OrderBy = orderBy; this.IsProjection = isProjection; var ce = ColumnExtractor.ExtractColumns(this, projection); this._Columns = ce.Columns.ToList(); this._Assignments = ce.Assignments.ToList(); }
protected virtual Expression VisitFrom(FromExpression from) { var source = (SourceExpression)this.Visit(from.From); if (source == from.From) return from; return CompleteExpression.From(source); }
protected override Expression VisitFrom(FromExpression from) { switch ((CompleteExpressionType)from.From.NodeType) { case CompleteExpressionType.Table: case CompleteExpressionType.Select: this.VisitSource(from.From); break; case CompleteExpressionType.Join: this.VisitJoin(from.From as JoinExpression); break; } this.AppendNewLine(Indentation.Same); return from; }
protected LambdaExpression VisitSelectProjection(FromExpression from, Expression expr) { var projection = VisitSourceReferencedProjection(from, expr); if (!projection.ReturnType.IsComplexType()) { var body = FixUpBooleanValue(projection.Body); var column = body as ColumnExpression; var name = column != null ? column.Name : string.Format("x{0:hhMMssffffff}", DateTime.UtcNow); projection = Expression.Lambda( CompleteExpression.Column( body, name), projection.Parameters.ToArray()); } return projection; }
protected LambdaExpression VisitSourceReferencedProjection(FromExpression from, Expression expression) { fromExpressions.Push(from); var projection = this.Visit(PartialEvaluator.Eval(expression.StripQuotes())) as LambdaExpression; fromExpressions.Pop(); return projection; }
public static SelectExpression Select(string alias, LambdaExpression projection, FromExpression from, OrderByClause orderBy, WhereExpression where = null, bool isProjection = true, Expression take = null) { return new SelectExpression(projection, from, where, alias, isProjection, take, orderBy); }