Update in-memory entity collection via Lambda expression

Posts   
 
    
can1
User
Posts: 77
Joined: 16-Sep-2005
# Posted on: 31-May-2010 22:42:05   

Hello,

I don't know if this is a question for the generated code forum or Linq forum, but I will try it here.

I have an EntityCollection<WhateverEntity>.

I want to set all the values of 1 particular field, for each entity in the collection, to a specific value. Currently, I iterate through the collection via for/each and set the field value.

Is there a way to perform an 'Update' to a property of each entity in the in memory EntityCollection<T> via a lambda expression or LL EntityCollection method via 1 line code?

Thanks.

Can1

Walaa avatar
Walaa
Support Team
Posts: 14995
Joined: 21-Aug-2005
# Posted on: 01-Jun-2010 09:26:17   

I don't know if there is a one line of code which can do this. But anyway this is not an LLBLGen issue, as it seems like Linq-2-Objects question rather than Linq-2-LLBLGen.

MTrinder
User
Posts: 1461
Joined: 08-Oct-2008
# Posted on: 01-Jun-2010 20:54:35   

If you are using .Net 3.5 you can use the .ForEach extension method, which performs a lambda specified function against each element in a set. I can't see that it will be a great deal faster or more efficient than doing it manually though.

Matt