You cannot just remove an element from IEnumerable .
But you can either make changes to the base collection (for example, if it is a List or something else), or filter out IEnumerable using the Where clause.
If you need to delete items, you must use a collection that supports the removal of items, such as List<> .
For example, you might have your background field of type List<foo> :
private List<foo> _listOfFoo; public IEnumerable<foo> listOfFoo { get { return _listOfFoo.AsReadOnly(); } set { _listOfFoo = value.ToList(); } }
And then remove the items from _listOfFoo .
_listOfFoo.Remove(_listOfFoo.Single(foo => foo.ID == id_to_remove));
source share