/// <summary> /// NOTE: This is called by the dOOdad framework and you should never call it. We reserve the right to remove or change this method. /// </summary> /// <param name="wItem">The AggregateParameter</param> public void AddAggregateParameter(AggregateParameter wItem) { if (_aggregateParameters == null) { _aggregateParameters = new ArrayList(); } _aggregateParameters.Add(wItem); // We don't allow Save() to succeed once they reduce the columns this._entity._canSave = false; }
protected string GetAggregate(AggregateParameter wItem, bool withAlias) { string query = string.Empty; switch (wItem.Function) { case AggregateParameter.Func.Avg: query += "AVG("; break; case AggregateParameter.Func.Count: query += "COUNT("; break; case AggregateParameter.Func.Max: query += "MAX("; break; case AggregateParameter.Func.Min: query += "MIN("; break; case AggregateParameter.Func.Sum: query += "SUM("; break; case AggregateParameter.Func.StdDev: query += "STDEV("; break; case AggregateParameter.Func.Var: query += "VAR("; break; } if (wItem.Distinct) { query += "DISTINCT "; } query += "[" + wItem.Column + "])"; if (withAlias && wItem.Alias != string.Empty) { // Need DBMS string delimiter here query += " AS '" + wItem.Alias + "'"; } return(query); }
public override void AddGroupBy(AggregateParameter aggregate) { // SQL Server does not support aggregates in a GROUP BY. // Common method base.AddGroupBy(GetAggregate(aggregate, false)); }
public override void AddOrderBy(AggregateParameter aggregate, PIKCV.DAO.WhereParameter.Dir direction) { base.AddOrderBy(GetAggregate(aggregate, false), direction); }
/// <summary> /// Overloaded to support aggregates. /// Derived classes implement this, like SqlClientDynamicQuery and OleDbDynamicQuery /// to account for differences in DBMS systems. /// </summary> /// <param name="aggregate">This should be an entry from your Aggregate class</param> /// <example> /// <code> /// emps.Query.AddGroupBy(emps.Aggregate.City)</code> /// </example> public virtual void AddGroupBy(AggregateParameter aggregate) { }
/// <summary> /// Overloaded to support aggregates. /// Derived classes implement this, like SqlClientDynamicQuery and OleDbDynamicQuery /// to account for differences in DBMS systems. /// </summary> /// <param name="aggregate">This should be an entry from your Aggregate class</param> /// <param name="direction">Either Descending or Ascending</param> /// <example> /// <code> /// emps.Query.AddOrderBy(emps.Aggregate.CategoryID, WhereParameter.Dir.ASC)</code> /// </example> public virtual void AddOrderBy(AggregateParameter aggregate, WhereParameter.Dir direction) { }