How to Add Expression Fields
27 Mar 2018 / 1 minute to read
To add an expression field to the data in the Grouping Engine, you must first create an instance of an ExpressionFieldDescriptor and add it to the ExpressionFields collection in the TableDescriptor. The ExpressionFieldDescriptor will allow you to specify a string that holds an algebraic expression using any of the other fields that are in the record.
The following code snippet illustrates this.
// Add an expression property that multiplies field B by 2.1 and adds 3.2
ExpressionFieldDescriptor expressionFieldDescriptor = new ExpressionFieldDescriptor("MultipleOfB", "2.1 * [B] + 3.2");
this.groupingEngine.TableDescriptor.ExpressionFields.Add(expressionFieldDescriptor);
// Assumes the datasource to be an IList, holding objects of type MyObject.
MyObject o = this.groupingEngine.Table.Records[2].GetData() as MyObject;
// MultipleOfB is an expression field name and B is a property in MyObject.
object someValue = this.groupingEngine.Table.Records[2].GetValue("B");
object someExpressionValue = this.groupingEngine.Table.Records[2].GetValue("MultipleOfB");
' Add an expression property that multiplies field B by 2.1 and adds 3.2
Dim expressionFieldDescriptor As New ExpressionFieldDescriptor("MultipleOfB", "2.1 * [B] + 3.2")
Me.groupingEngine.TableDescriptor.ExpressionFields.Add(expressionFieldDescriptor)
' Assumes the datasource to be an IList, holding objects of type MyObject.
Dim o As MyObject = CType(Me.groupingEngine.Table.Records(2).GetData(), MyObject)
' MultipleOfB is an expression field name and B is a Property in MyObject.
Dim someValue As Object = Me.groupingEngine.Table.Records(2).GetValue("B")
Dim someExpressionValue As Object = Me.groupingEngine.Table.Records(2).GetValue("MultipleOfB")
Was this page helpful?
Yes
No
Thank you for your feedback!
Thank you for your feedback and comments. We will rectify this as soon as possible!
An unknown error has occurred. Please try again.
Help us improve this page