Performing Aggregate Calculations
The Compute( )
method computes the result of an
aggregate query on the rows in the table that meet the filter
criteria. Here’s an example that illustrates this:
DataTable dt = new Table(); dt.Columns.Add("OrderId", typeof(System.Int32)); dt.Columns.Add("OrderAmount", typeof(System.Decimal)); // ... add some rows // computes the sum of order amounts for all orders with Id less than 10 Decimal totalOrderAmount = dt.Compute("SUM(OrderAmount)", "OrderId<10")
Get ADO.NET in a Nutshell now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.