/// <summary>
 /// Gets the textual representation of the <paramref name="aggregateFunctionExpressionType"/>
 /// </summary>
 /// <param name="aggregateFunctionExpressionType">The <see cref="DbAggregateFunctionExpressionType"/> for which to return the textual representation.</param>
 /// <returns><see cref="string"/></returns>
 protected virtual string GetAggregateFunctionBody(DbAggregateFunctionExpressionType aggregateFunctionExpressionType)
 {
     switch (aggregateFunctionExpressionType)
     {
         case DbAggregateFunctionExpressionType.Avg:
             return "AVG({0})";
         case DbAggregateFunctionExpressionType.Count:
             return "COUNT({0})";
         case DbAggregateFunctionExpressionType.Max:
             return "MAX({0})";
         case DbAggregateFunctionExpressionType.Min:
             return "MIN({0})";
         case DbAggregateFunctionExpressionType.Sum:
             return "SUM({0})";
         default:
             throw new ArgumentOutOfRangeException("aggregateFunctionExpressionType", aggregateFunctionExpressionType, " is not supported");
     }
 }
        /// <summary>
        /// Gets the textual representation of the <paramref name="aggregateFunctionExpressionType"/>
        /// </summary>
        /// <param name="aggregateFunctionExpressionType">The <see cref="DbAggregateFunctionExpressionType"/> for which to return the textual representation.</param>
        /// <returns><see cref="string"/></returns>
        protected virtual string GetAggregateFunctionBody(DbAggregateFunctionExpressionType aggregateFunctionExpressionType)
        {
            switch (aggregateFunctionExpressionType)
            {
            case DbAggregateFunctionExpressionType.Avg:
                return("AVG({0})");

            case DbAggregateFunctionExpressionType.Count:
                return("COUNT({0})");

            case DbAggregateFunctionExpressionType.Max:
                return("MAX({0})");

            case DbAggregateFunctionExpressionType.Min:
                return("MIN({0})");

            case DbAggregateFunctionExpressionType.Sum:
                return("SUM({0})");

            default:
                throw new ArgumentOutOfRangeException("aggregateFunctionExpressionType", aggregateFunctionExpressionType, " is not supported");
            }
        }
 private void ValidateAggregateExpression(DbAggregateFunctionExpression aggregateFunctionExpression, DbAggregateFunctionExpressionType aggregateFunctionExpressionType)
 {
     Assert.IsTrue(aggregateFunctionExpression.ExpressionType == DbExpressionType.Function);
     Assert.IsTrue(aggregateFunctionExpression.FunctionExpressionType == DbFunctionExpressionType.Aggregate);
     Assert.IsNotNull(aggregateFunctionExpression.Arguments);
     Assert.IsTrue(aggregateFunctionExpression.Arguments.Length > 0);
 }
 private void ValidateAggregateExpression(DbAggregateFunctionExpression aggregateFunctionExpression, DbAggregateFunctionExpressionType aggregateFunctionExpressionType)
 {
     Assert.IsTrue(aggregateFunctionExpression.ExpressionType == DbExpressionType.Function);
     Assert.IsTrue(aggregateFunctionExpression.FunctionExpressionType == DbFunctionExpressionType.Aggregate);
     Assert.IsNotNull(aggregateFunctionExpression.Arguments);
     Assert.IsTrue(aggregateFunctionExpression.Arguments.Length > 0);
 }
 /// <summary>
 /// Creates a <see cref="DbAggregateFunctionExpression"/>.
 /// </summary>
 /// <param name="aggregateFunctionExpressionType">The <see cref="DbAggregateFunctionExpressionType"/> that specifies the type of aggregate expression to create.</param>
 /// <param name="target">The <see cref="DbExpression"/> that the aggregate function operates on.</param>
 /// <returns>A <see cref="DbAggregateFunctionExpression"/> instance.</returns>
 public DbAggregateFunctionExpression MakeAggregateFunction(DbAggregateFunctionExpressionType aggregateFunctionExpressionType, DbExpression target)
 {
     var aggregateExpression = new DbAggregateFunctionExpression(aggregateFunctionExpressionType, new[] { target });
     return aggregateExpression;
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="DbAggregateFunctionExpression"/> class.
 /// </summary>
 /// <param name="aggregateFunctionExpressionType">The <see cref="DbAggregateFunctionExpressionType"/> of the <see cref="DbAggregateFunctionExpression"/>.</param>
 /// <param name="arguments">The arguments used when calling the function.</param>
 internal DbAggregateFunctionExpression(DbAggregateFunctionExpressionType aggregateFunctionExpressionType, DbExpression[] arguments)
     : base(DbFunctionExpressionType.Aggregate, arguments)
 {
     AggregateFunctionExpressionType = aggregateFunctionExpressionType;
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="DbAggregateFunctionExpression"/> class.
 /// </summary>
 /// <param name="aggregateFunctionExpressionType">The <see cref="DbAggregateFunctionExpressionType"/> of the <see cref="DbAggregateFunctionExpression"/>.</param>
 /// <param name="arguments">The arguments used when calling the function.</param>
 internal DbAggregateFunctionExpression(DbAggregateFunctionExpressionType aggregateFunctionExpressionType, DbExpression[] arguments)
     : base(DbFunctionExpressionType.Aggregate, arguments)
 {
     AggregateFunctionExpressionType = aggregateFunctionExpressionType;
 }