VS2005
llblGenPro: 1.0.2005.1
designer version: 1.0.2005.1
adapter: selfServicing
hiya,
I have been browsing thru all the topics, but I'm still a bit stuck.
I need to calculate the entire value of an order.
tblOrder
orderId PK
productId FK
qty
tblProduct
productId PK
unitPrice
So, I think I have to:
1) filter the orderEntityCollection with the orderId
2) iterate thru each product in tblOrder obtaining the qty (using productId as a fliter?)
3) multiply qty with the corresponding tblProduct.unitPrice
4) SUM all of the values to obtain a grand total
I know that the above is all fairly standard stuff.The thing is, that I have been following the northwindCS example..but then I saw the improved code that Frans posted...
IExpression expOp1 = ((OrderDetailsFields.UnitPrice * OrderDetailsFields.Quantity) -
(OrderDetailsFields.UnitPrice * OrderDetailsFields.Quantity * OrderDetailsFields.Discount / 100));
EntityField2 op1 = OrderDetailsFields.UnitPrice.SetAggregateFunction(AggregateFunction.Sum).SetExpression(expOp1);
IExpression scalarExpression = op1 / OrderDetailsFields.Quantity.SetAggregateFunction(AggregateFunction.Sum);
etc
When I saw that code, I got a bit more confused, because it seemed to open up even more permutations. Could anyone comment on the best approach for a quick solution..I can tidy it up later :-)
as ever, many thanks,
yogi