views:

101

answers:

2

Let's say we have the "EntityCollection products".

Then the following doesn't work:

foreach (var product in products)
{
 product.LastUpdate = DateTime.Now();
}

As you can also not index an EntityCollection, how do you modify an entity in en EntityCollection?

A: 

Could you try this?

foreach (var product in products.ToArray())
{
     product.LastUpdate = DateTime.Now();
}

You have to copy elements for enumeration with ToArray(), so you can change products.

LukLed