v2.6
I am trying to create a new field that performs addition/subtraction of the results of the subquery defined in other fields without having to repeat the code again.
Resultset fields = new ResultsetFields(4);
fields.DefineField(new EntityField("OnOrder", new ScalarQueryExpression(OrderItemFields.ProductId.SetAggregateFunction(AggregateFunction.Count), onOrderPredicateFilter)), 0);
fields.DefineField(new EntityField("Sold", new ScalarQueryExpression(SalesItemFields.ProductId.SetAggregateFunction(AggregateFunction.Count), soldPredicateFilter)), 1);
fields.DefineField(ProductFields.Inventory, 2, "Inventory");
Effectively what I'd like to do is:
fields.DefineField(fields[1] - fields[0] - fields[2], 3, "Needed");
I have read the ScalarQueryExpression and Expression documentation and searched the forums for a combination of "ScalarQueryExpression", "Expression", "ResultsetFields", "EntityField", and "Reference".
Question(s):
1) How do I refer to the EntityField / ScalarQueryExpression that was defined already in the ResultsetFields,
2) Can I refer to this in the ResultsetFields.DefineField() or does this need to be defined in a separate EntityField expression?
3) or do I need to repeat all of the code again in the ResultsetFields.DefineField for field index 3?
Thanks!