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 EntityCollect开发者_StackOverflow中文版ion, how do you modify an entity in en EntityCollection?
Try this, i create a generic method to update EntityCollection. Giv me your feed back.
You juste have to modify your product in your products entity collections. And call my GenericUpdateEntityCollection(YourEntityCollection, YourObjectContext);
and there you go
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
.
精彩评论