internal static Expression Parameterize(TableAlias outerAlias, Expression expr) { OuterParameterizer op = new OuterParameterizer(); op.outerAlias = outerAlias; return(op.Visit(expr)); }
/// <summary> /// Executes the projection. /// </summary> /// <param name="projection">The projection.</param> /// <param name="okayToDefer">if set to <c>true</c> [okay to defer].</param> /// <returns></returns> private Expression ExecuteProjection(ProjectionExpression projection, bool okayToDefer) { // parameterize query projection = (ProjectionExpression)this.Parameterize(projection); if (this.scope != null) { // also convert references to outer alias to named values! these become SQL parameters too projection = (ProjectionExpression)OuterParameterizer.Parameterize(this.scope.Alias, projection); } FixColumnNames(projection); string commandText = this.linguist.Format(projection.Select); ReadOnlyCollection <NamedValueExpression> namedValues = NamedValueGatherer.Gather(projection.Select); QueryCommand command = new QueryCommand(commandText, namedValues.Select(v => new QueryParameter(v.Name, v.Type))); Expression[] values = namedValues.Select(v => Expression.Convert(this.Visit(v.Value), typeof(object))).ToArray(); return(this.ExecuteProjection(projection, okayToDefer, command, values)); }