DbContext.RemoveRange DbContext.RemoveRange Method

Definition

Overloads

RemoveRange(Object[]) RemoveRange(Object())

Begins tracking the given entity in the Deleted state such that it will be removed from the database when SaveChanges() is called.

RemoveRange(IEnumerable<Object>) RemoveRange(IEnumerable(Of Object))

Begins tracking the given entity in the Deleted state such that it will be removed from the database when SaveChanges() is called.

RemoveRange(Object[]) RemoveRange(Object())

Begins tracking the given entity in the Deleted state such that it will be removed from the database when SaveChanges() is called.

public virtual void RemoveRange(params object[] entities)
Public Overridable Sub RemoveRange(ParamArray entities As Object())

Parameters

entities
System.Object[] System.Object()

The entities to remove.

Remarks

If any of the entities are already tracked in the Added state then the context will stop tracking those entities (rather than marking them as Deleted) since those entities were previously added to the context and do not exist in the database.

Any other reachable entities that are not already being tracked will be tracked in the same way that they would be if AttachRange(Object[]) was called before calling this method. This allows any cascading actions to be applied when SaveChanges() is called.

RemoveRange(IEnumerable<Object>) RemoveRange(IEnumerable(Of Object))

Begins tracking the given entity in the Deleted state such that it will be removed from the database when SaveChanges() is called.

public virtual void RemoveRange(IEnumerable<object> entities)
Public Overridable Sub RemoveRange(entities As IEnumerable(Of Object))

Parameters

entities
System.Collections.Generic.IEnumerable<System.Object> System.Collections.Generic.IEnumerable(Of System.Object)

The entities to remove.

Remarks

If any of the entities are already tracked in the Added state then the context will stop tracking those entities (rather than marking them as Deleted) since those entities were previously added to the context and do not exist in the database.

Any other reachable entities that are not already being tracked will be tracked in the same way that they would be if AttachRange(IEnumerable<Object>) was called before calling this method. This allows any cascading actions to be applied when SaveChanges() is called.