Creating Expression Columns
You can define an expression for a column, enabling it to contain a value calculated from other column values in the same row or from the column values of multiple rows in the table. To define the expression to be evaluated, use theproperty of the target column, and use the property to refer to other columns in the expression. The for the expression column must be appropriate for the value that the expression returns.
The following table lists several possible uses for expression columns in a table.
"Total >= 500"
"UnitPrice * Quantity"
You can set the Expression property on an existing DataColumn object, or you can include the property as the third argument passed to theconstructor, as shown in the following example.
workTable.Columns.Add("Total", typeof(Double)); workTable.Columns.Add("SalesTax", typeof(Double), "Total * 0.086");
Expressions can reference other expression columns; however, a circular reference, in which two expressions reference each other, will generate an exception. For rules about writing expressions, see the Expression property of the DataColumn class.