I've a listView that contains a collection of items that have the property IsFavourite
, what I'm trying to do is set this property to false, for each items that was found in the Where
clause.
What I did is this:
myListView.Items.Cast<Event>().Where(x => x.MatchLeague == leagueName && x.MatchNation == nationName).Select(c => { c.IsFavourite = false; return c; }).ToList();
so essentially I take all the items that have a certain leagueName
and nationName
, after did this, I tried to set for all items returned the IsFavourite
property to false, and return the items as a list.
But I get this exception:
Operation is not valid due to the current state of the object
I've no idea what am I doing wrong, I even use this type of code in the past and all working well, what happen? Thanks.