Northwind Sample Question

Posts   
 
    
JeffD
User
Posts: 4
Joined: 07-Jan-2005
# Posted on: 12-Jan-2005 00:55:34   

This is just a clarifying question:

Mainform.cs, starting at line 81

// get all order prices ResultsetFields orderPricesFields = new ResultsetFields(2); orderPricesFields.DefineField(OrderDetailsFieldIndex.OrderID, 0, "OrderID"); orderPricesFields.DefineField(OrderDetailsFieldIndex.ProductID, 1, "OrderPrice", "", AggregateFunction.Sum); IExpression productPriceExpression = new Expression( EntityFieldFactory.Create(OrderDetailsFieldIndex.Quantity), ExOp.Mul, EntityFieldFactory.Create(OrderDetailsFieldIndex.UnitPrice)); orderPricesFields[1].ExpressionToApply = productPriceExpression; IGroupByCollection groupBy = new GroupByCollection(); groupBy.Add(orderPricesFields[0]);

I think I follow all of this except for line 84. Why was ProductID selected? It doesn't seem to be used for anything, and I used Discount instead, and it doesn't appear to have altered the outcome at all. Am I correct in my assumption that the productPriceExpression overrides this value?

Thanks.

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39933
Joined: 17-Aug-2003
# Posted on: 12-Jan-2005 10:36:18   

Any field will do, as the field itself is replaced by the expression assigned in the query. As fields are used for expression placeholders, this is the way to go. I also could have used a dummy field, I opted for this shortcut.

Frans Bouma | Lead developer LLBLGen Pro