I have an entity infrastructure EntityCollection.
I need to remove all elements matching the where where query from the database. This is my existing code:
foreach (var deleteReq in order.Requirements.Where(x=>!orderContract.Requirements.Any(y=>y.RequirementId==x.RequirementId)))
{
order.Requirements.Remove(deleteReq);
}
I am basically trying to remove something from the order.Requirements of a collection that is not in the orderContract.Requirements of the collection (matching on Id).
As you can guess, this code generates and excludes because I am modifying the collection that I am executing.
Normally I would just use RemoveAll(), but EntityCollectiondoes not support this method.
So ... How can I delete all the records that I need?
source
share