daily pastebin goal
75%
SHARE
TWEET

Untitled

a guest Aug 19th, 2018 66 Never
Upgrade to PRO!
ENDING IN00days00hours00mins00secs
  1. How to remove a subset of items from an Entity Framework Collection
  2. // Perform the deletes
  3. foreach (var deleteReq in order.Requirements.Where(x=>!orderContract.Requirements.Any(y=>y.RequirementId==x.RequirementId)))
  4. {
  5.     order.Requirements.Remove(deleteReq);
  6. }
  7.    
  8. // Perform the deletes
  9. var reqsToDelete = order.Requirements.Where(x=>!orderContract.Requirements.Any(y=>y.RequirementId==x.RequirementId)).ToList();
  10. foreach (var deleteReq in reqsToDelete)
  11. {
  12.     order.Requirements.Remove(deleteReq);
  13. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top