/// <summary> /// Generates the 'SELECT' part of an <see cref="SubSonic.Query.Aggregate"/> /// </summary> /// <param name="aggregate">The aggregate to include in the SELECT clause</param> /// <returns>The portion of the SELECT clause represented by this <see cref="SubSonic.Query.Aggregate"/></returns> /// <remarks> /// The ToString() logic moved from <see cref="SubSonic.Query.Aggregate.ToString"/>, rather than /// including it in the Aggregate class itself... /// </remarks> protected virtual string GenerateAggregateSelect(SubSonic.Query.Aggregate aggregate) { bool hasAlias = !String.IsNullOrEmpty(aggregate.Alias); if (aggregate.AggregateType == AggregateFunction.GroupBy && hasAlias) { return(String.Format("{0} AS {1}", aggregate.ColumnName, aggregate.Alias)); } if (aggregate.AggregateType == AggregateFunction.GroupBy) { return(string.Format("{0}", aggregate.ColumnName)); } if (hasAlias) { return(String.Format("{0}({1}) AS {2}", SubSonic.Query.Aggregate.GetFunctionType(aggregate).ToUpper(), aggregate.ColumnName, aggregate.Alias)); } return(String.Format("{0}({1})", SubSonic.Query.Aggregate.GetFunctionType(aggregate).ToUpper(), aggregate.ColumnName)); }
/// <summary> /// Groups the by. /// </summary> /// <param name="columnName">Name of the column.</param> /// <param name="alias">The alias.</param> /// <returns></returns> public static Aggregate GroupBy(string columnName, string alias) { Aggregate agg = new Aggregate(columnName, alias, AggregateFunction.GroupBy); return(agg); }
protected override string GenerateAggregateSelect(Aggregate aggregate) { bool hasAlias = !String.IsNullOrEmpty(aggregate.Alias); if(aggregate.AggregateType == AggregateFunction.GroupBy && hasAlias) return String.Format("`{0}` AS `{1}`", aggregate.ColumnName, aggregate.Alias); if(aggregate.AggregateType == AggregateFunction.GroupBy) return string.Format("`{0}`", aggregate.ColumnName); if(hasAlias) { return String.Format("{0}(`{1}`) AS `{2}`", Aggregate.GetFunctionType(aggregate).ToUpper(), aggregate.ColumnName, aggregate.Alias); } return String.Format("{0}(`{1}`)", Aggregate.GetFunctionType(aggregate).ToUpper(), aggregate.ColumnName); }
/// <summary> /// Counts the specified column name. /// </summary> /// <param name="columnName">Name of the column.</param> /// <param name="alias">The alias.</param> /// <returns></returns> public static Aggregate Count(string columnName, string alias) { Aggregate agg = new Aggregate(columnName, alias, AggregateFunction.Count); return agg; }
/// <summary> /// Counts the specified col. /// </summary> /// <param name="col">The col.</param> /// <returns></returns> public static Aggregate Count(IColumn col) { Aggregate agg = new Aggregate(col, AggregateFunction.Count); return agg; }
/// <summary> /// Standards the deviation. /// </summary> /// <param name="col">The col.</param> /// <returns></returns> public static Aggregate StandardDeviation(IColumn col) { Aggregate agg = new Aggregate(col, AggregateFunction.StDev); return agg; }
/// <summary> /// Variances the specified col. /// </summary> /// <param name="col">The col.</param> /// <returns></returns> public static Aggregate Variance(IColumn col) { Aggregate agg = new Aggregate(col, AggregateFunction.Var); return agg; }
/// <summary> /// Mins the specified column name. /// </summary> /// <param name="columnName">Name of the column.</param> /// <returns></returns> public static Aggregate Min(string columnName) { Aggregate agg = new Aggregate(columnName, AggregateFunction.Min); return agg; }
/// <summary> /// Standards the deviation. /// </summary> /// <param name="col">The col.</param> /// <returns></returns> public static Aggregate StandardDeviation(IColumn col) { Aggregate agg = new Aggregate(col, AggregateFunction.StDev); return(agg); }
/// <summary> /// Variances the specified column name. /// </summary> /// <param name="columnName">Name of the column.</param> /// <param name="alias">The alias.</param> /// <returns></returns> public static Aggregate Variance(string columnName, string alias) { Aggregate agg = new Aggregate(columnName, alias, AggregateFunction.Var); return(agg); }
/// <summary> /// Variances the specified col. /// </summary> /// <param name="col">The col.</param> /// <returns></returns> public static Aggregate Variance(IColumn col) { Aggregate agg = new Aggregate(col, AggregateFunction.Var); return(agg); }
/// <summary> /// Mins the specified col. /// </summary> /// <param name="col">The col.</param> /// <param name="alias">The alias.</param> /// <returns></returns> public static Aggregate Min(IColumn col, string alias) { Aggregate agg = new Aggregate(col, alias, AggregateFunction.Min); return(agg); }
/// <summary> /// Mins the specified column name. /// </summary> /// <param name="columnName">Name of the column.</param> /// <returns></returns> public static Aggregate Min(string columnName) { Aggregate agg = new Aggregate(columnName, AggregateFunction.Min); return(agg); }
/// <summary> /// Mins the specified col. /// </summary> /// <param name="col">The col.</param> /// <returns></returns> public static Aggregate Min(IColumn col) { Aggregate agg = new Aggregate(col, AggregateFunction.Min); return(agg); }
/// <summary> /// Avgs the specified col. /// </summary> /// <param name="col">The col.</param> /// <returns></returns> public static Aggregate Avg(IColumn col) { Aggregate agg = new Aggregate(col, AggregateFunction.Avg); return agg; }
/// <summary> /// Mins the specified col. /// </summary> /// <param name="col">The col.</param> /// <returns></returns> public static Aggregate Min(IColumn col) { Aggregate agg = new Aggregate(col, AggregateFunction.Min); return agg; }
/// <summary> /// Standards the deviation. /// </summary> /// <param name="columnName">Name of the column.</param> /// <param name="alias">The alias.</param> /// <returns></returns> public static Aggregate StandardDeviation(string columnName, string alias) { Aggregate agg = new Aggregate(columnName, alias, AggregateFunction.StDev); return(agg); }
/// <summary> /// Mins the specified col. /// </summary> /// <param name="col">The col.</param> /// <param name="alias">The alias.</param> /// <returns></returns> public static Aggregate Min(IColumn col, string alias) { Aggregate agg = new Aggregate(col, alias, AggregateFunction.Min); return agg; }
/// <summary> /// Counts the specified col. /// </summary> /// <param name="col">The col.</param> /// <returns></returns> public static Aggregate Count(IColumn col) { Aggregate agg = new Aggregate(col, AggregateFunction.Count); return(agg); }
/// <summary> /// Variances the specified column name. /// </summary> /// <param name="columnName">Name of the column.</param> /// <param name="alias">The alias.</param> /// <returns></returns> public static Aggregate Variance(string columnName, string alias) { Aggregate agg = new Aggregate(columnName, alias, AggregateFunction.Var); return agg; }
/// <summary> /// Gets the type of the function. /// </summary> /// <param name="agg">The agg.</param> /// <returns></returns> public static string GetFunctionType(Aggregate agg) { return(Enum.GetName(typeof(AggregateFunction), agg.AggregateType)); }
/// <summary> /// Standards the deviation. /// </summary> /// <param name="columnName">Name of the column.</param> /// <param name="alias">The alias.</param> /// <returns></returns> public static Aggregate StandardDeviation(string columnName, string alias) { Aggregate agg = new Aggregate(columnName, alias, AggregateFunction.StDev); return agg; }
/// <summary> /// Counts the specified column name. /// </summary> /// <param name="columnName">Name of the column.</param> /// <param name="alias">The alias.</param> /// <returns></returns> public static Aggregate Count(string columnName, string alias) { Aggregate agg = new Aggregate(columnName, alias, AggregateFunction.Count); return(agg); }
/// <summary> /// Gets the type of the function. /// </summary> /// <param name="agg">The agg.</param> /// <returns></returns> public static string GetFunctionType(Aggregate agg) { return Enum.GetName(typeof(AggregateFunction), agg.AggregateType); }
/// <summary> /// Sums the specified col. /// </summary> /// <param name="col">The col.</param> /// <returns></returns> public static Aggregate Sum(IColumn col) { Aggregate agg = new Aggregate(col, AggregateFunction.Sum); return(agg); }
/// <summary> /// Sums the specified col. /// </summary> /// <param name="col">The col.</param> /// <returns></returns> public static Aggregate Sum(IColumn col) { Aggregate agg = new Aggregate(col, AggregateFunction.Sum); return agg; }
/// <summary> /// Groups the by. /// </summary> /// <param name="col">The col.</param> /// <returns></returns> public static Aggregate GroupBy(IColumn col) { Aggregate agg = new Aggregate(col, AggregateFunction.GroupBy); return agg; }
/// <summary> /// Groups the by. /// </summary> /// <param name="columnName">Name of the column.</param> /// <param name="alias">The alias.</param> /// <returns></returns> public static Aggregate GroupBy(string columnName, string alias) { Aggregate agg = new Aggregate(columnName, alias, AggregateFunction.GroupBy); return agg; }
/// <summary> /// Groups the by. /// </summary> /// <param name="col">The col.</param> /// <returns></returns> public static Aggregate GroupBy(IColumn col) { Aggregate agg = new Aggregate(col, AggregateFunction.GroupBy); return(agg); }