chungpn wrote:
This code only update the record 0 of Orders table.
Yes, because you are only updating that order.
chungpn wrote:
How can I update all related records in the Orders table? Do I need loop all the items in the _currentCustomer.Orders collection to update?
That is an option, as a matter of fact if you will set different Freight values for each order then this is the way to go.
Now, if you want to set 126 Freight value for all orders related to that customer in the DB, then it would be faster to Update all orders directly:
OrderCollection orders = new OrderCollection();
OrderEntity orderUpdate = new OrderEntity();
orderUpdate.Freight = 126;
IPredicateExpression selectFilter = new PredicateExpression(
OrderFields.CustomerId ==_currentCustomer.CustomerId));
int amountRowsAffected = orders.UpdateMulti(orderUpdate, selectFilter, null);