EasyObjects.NET Programmers Reference

AggregateParameter Class

This class is dynamcially created when you add an AggregateParameter to your EasyObject's DynamicQuery (See the EasyObject.Query).

For a list of all members of this type, see AggregateParameter Members.

System.Object
   NCI.EasyObjects.ValueParameter
      NCI.EasyObjects.AggregateParameter

public class AggregateParameter : ValueParameter

Thread Safety

Public static (Shared in Visual Basic) members of this type are safe for multithreaded operations. Instance members are not guaranteed to be thread-safe.

Remarks

Aggregate and GROUP BY Feature Support by DBMS:

                MS    
Feature         SQL   Oracle
--------------- ----- ------
Avg              Y     Y
Count            Y     Y
Max              Y     Y
Min              Y     Y
Sum              Y     Y
StdDev           Y    (1)
Var              Y     Y
Aggregate in
  ORDER BY       Y     Y
  GROUP BY       -     Y
WITH ROLLUP      Y     Y
COUNT(DISTINCT)  Y     Y

Notes:
  (1) - Uses TRUNC(STDDEV(column),10) to avoid overflow errors
  
This will be the extent of your use of the AggregateParameter class, this class is mostly used by the EasyObject architecture, not the programmer.
prds  = new Products();

// To include a COUNT(*) with NULLs included
prds.Query.CountAll = true;
prds.Query.CountAllAlias = "Product Count";

// To exclude NULLs in the COUNT for a column
prds.Aggregate.UnitsInStock.Function = AggregateParameter.Func.Count;
prds.Aggregate.UnitsInStock.Alias = "With Stock";

// To have two aggregates for the same column, use a tearoff
AggregateParameter ap = prds.Aggregate.TearOff.UnitsInStock;
ap.Function = AggregateParameter.Func.Sum;
ap.Alias = "Total Units";

prds.Aggregate.ReorderLevel.Function = AggregateParameter.Func.Avg;
prds.Aggregate.ReorderLevel.Alias = "Avg Reorder";

prds.Aggregate.UnitPrice.Function = AggregateParameter.Func.Min;
prds.Aggregate.UnitPrice.Alias = "Min Price";

ap = prds.Aggregate.TearOff.UnitPrice;
ap.Function = AggregateParameter.Func.Max;
ap.Alias = "Max Price";

// If you have no aggregates or AddResultColumns,
// Then the query defaults to SELECT *
// If you have an aggregate and no AddResultColumns,
// Then only aggregates are reurned in the query.
prds.Query.AddResultColumn(Products.ColumnNames.CategoryID);
prds.Query.AddResultColumn(Products.ColumnNames.Discontinued);

// If you have an Aggregate, ANSI SQL requires an AddGroupBy
// for each AddResultColumn. Check your DBMS docs.
prds.Query.AddGroupBy(Products.ColumnNames.CategoryID);
prds.Query.AddGroupBy(Products.ColumnNames.Discontinued);

prds.Query.AddOrderBy(Products.ColumnNames.Discontinued, WhereParameter.Dir.ASC);

// You can use aggregates in AddOrderBy by
// referencing either the EasyObject AggregateParameter or a tearoff
// You must create the aggregate before using it here.
prds.Query.AddOrderBy(prds.Aggregate.UnitsInStock, WhereParameter.Dir.DESC);

// Load it.
prds.Query.Load();

Requirements

Namespace: NCI.EasyObjects

Assembly: NCI.EasyObjects (in NCI.EasyObjects.dll)

See Also

AggregateParameter Members | NCI.EasyObjects Namespace