I have IQueryable
baseList
and List
someData
What I want to do is update attributes in some
You can convert the IQueryable
into a List
, use the ForEach
method to loop over it and update the elements, then convert back to IQueryable
:
List convertedList = baseList.ToList();
convertedList.ForEach(sc =>
{
SomeOtherClass oc = someData.First(obj => obj.SomeCode == sc.MyCode);
if (oc != null)
{
sc.SomeData += oc.DataIWantToConcatenate;
}
});
baseList = convertedList.AsQueryable(); // back to IQueryable
But it may be more efficient during this using non-LINQ constructs.