private void Write(string name, DbAggregate aggregate) { WriteLine(string.Format("{0} ({1}): {2}", name, aggregate.GetType().Name, aggregate.ResultType)); _depth++; Write("Arguments", aggregate.Arguments); _depth--; }
public virtual void VisitAggregate(DbAggregate aggregate) { if (aggregate == null) { throw new ArgumentException("aggregate"); } VisitExpressionList(aggregate.Arguments); }
private VfpAggregate CreateDbAggregate(DbAggregate aggregate) { var functionAggregate = aggregate as DbFunctionAggregate; if (functionAggregate != null) { return(new VfpFunctionAggregate(functionAggregate.ResultType, CreateDbExpressionList(functionAggregate.Arguments), functionAggregate.Function, functionAggregate.Distinct)); } throw new NotImplementedException(aggregate.GetType().ToString()); }
public override SqlFragment Visit(DbGroupByExpression expression) { // first process the input DbGroupExpressionBinding e = expression.Input; SelectStatement innerSelect = VisitInputExpressionEnsureSelect(e.Expression, e.VariableName, e.VariableType); scope.Add(e.GroupVariableName, innerSelect); SelectStatement select = WrapIfNotCompatible(innerSelect, expression.ExpressionKind); CollectionType ct = (CollectionType)expression.ResultType.EdmType; RowType rt = (RowType)ct.TypeUsage.EdmType; int propIndex = 0; foreach (DbExpression key in expression.Keys) { var fragment = key.Accept(this); select.AddGroupBy(fragment); propIndex++; var colFragment = fragment as ColumnFragment; if (colFragment != null) { colFragment = colFragment.Clone(); colFragment.ColumnAlias = String.Format("K{0}", propIndex); select.Columns.Add(colFragment); } } for (int agg = 0; agg < expression.Aggregates.Count; agg++) { DbAggregate a = expression.Aggregates[agg]; DbFunctionAggregate fa = a as DbFunctionAggregate; if (fa == null) { throw new NotSupportedException(); } string alias = rt.Properties[propIndex++].Name; ColumnFragment functionCol = new ColumnFragment(null, null); functionCol.Literal = HandleFunction(fa, a.Arguments[0].Accept(this)); functionCol.ColumnAlias = alias; select.Columns.Add(functionCol); } return(select); }
/// <summary> /// Aggregates are not visited by the normal visitor walk. /// </summary> /// <param name="aggregate">The aggreate go be translated</param> /// <param name="aggregateArgument">The translated aggregate argument</param> /// <returns></returns> private SqlBuilder VisitAggregate(DbAggregate aggregate, ISqlFragment aggregateArgument) { SqlBuilder aggregateResult = new SqlBuilder(); DbFunctionAggregate functionAggregate = aggregate as DbFunctionAggregate; if (functionAggregate == null) { throw new NotSupportedException(); } //The only aggregate function with different name is Big_Count //Note: If another such function is to be added, a dictionary should be created if (MetadataHelpers.IsCanonicalFunction(functionAggregate.Function) && String.Equals(functionAggregate.Function.Name, "BigCount", StringComparison.Ordinal)) { aggregateResult.Append("COUNT_BIG"); } else { WriteFunctionName(aggregateResult, functionAggregate.Function); } aggregateResult.Append("("); DbFunctionAggregate fnAggr = functionAggregate; if ((null != fnAggr) && (fnAggr.Distinct)) { aggregateResult.Append("DISTINCT "); } aggregateResult.Append(aggregateArgument); aggregateResult.Append(")"); return(aggregateResult); }
private bool VisitAggregate(DbAggregate aggregate) { return(VisitExpressionList(aggregate.Arguments)); }
internal void AttachToAstNode(string aggregateName, DbAggregate aggregateDefinition) { DebugCheck.NotNull(aggregateDefinition); base.AttachToAstNode(aggregateName, aggregateDefinition.ResultType); AggregateDefinition = aggregateDefinition; }
public virtual void VisitAggregate(DbAggregate aggregate) { if (aggregate == null) throw new ArgumentException("aggregate"); VisitExpressionList(aggregate.Arguments); }
public virtual void VisitAggregate(DbAggregate aggregate) { this.VisitExpressionList(EntityUtils.CheckArgumentNull <DbAggregate>(aggregate, nameof(aggregate)).Arguments); }
/// <summary> /// Convenience method to visit the specified <see cref="DbAggregate" />. /// </summary> /// <param name="aggregate"> The aggregate to visit. </param> /// <exception cref="ArgumentNullException"> /// <paramref name="aggregate" /> /// is null /// </exception> public virtual void VisitAggregate(DbAggregate aggregate) { // #433613: PreSharp warning 56506: Parameter 'aggregate' to this public method must be validated: A null-dereference can occur here. VisitExpressionList(Check.NotNull(aggregate, "aggregate").Arguments); }
internal void AttachToAstNode(string aggregateName, DbAggregate aggregateDefinition) { this.AttachToAstNode(aggregateName, aggregateDefinition.ResultType); this.AggregateDefinition = aggregateDefinition; }