I see nothing wrong with
foreach
, but try to carry
SaveChanges
out of the loop. If you really have a performance leak related to
foreach
, it's rather in repeated
SaveChanges
. There is no need to repeat it for each object.
Try:
foreach (var @object in tag)
objLib.TagsField.Context.DeleteObject(@object);
objLib.SaveChanges();
—SA