How to delete a list of objects in EF6 when the object is detached from the context

c# entity-framework entity-framework-6

Accepted Answer

ZZZ_tmp
2
11/23/2017 2:42:28 PM

Popular Answer

You may utilizeRemoveRange :

context.MY_GROUPS.RemoveRange(context.MY_GROUPS.Where(x => x.columnName== "Foo"));

Additionally, utilizeForEach as in this:

context.MY_GROUPS.Where(x => x.columnName == "Foo").ToList().ForEach(context.DeleteObject);
context.SaveChanges();

You might try ObjectContext.ExecuteStoreCommand Method as an alternative strategy for this.



Related Questions





Related

Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow