Sunday, October 20, 2019

The "Compute" method of the DataTable class

The "Compute" method of the System.Data.DataTable class of .NET framework is a useful function for doing further calculation. Specially getting rows of data from Database or other sources and then executing further calculation in the server memories(RAM).

 public object Compute(string expression, string filter)

It Computes the given expression like SUM or Count, on the current rows with fileter if needs.The filter is to limit the rows.The "filter" is like "WHERE" portion in SQL

Example Code C#

string output = dtData.Compute("Sum(ItemQuantity)","ItemQuality ='HIGH'").ToString();

No comments: