Share via


DbSet<TEntity>.UpdateRange Method

Definition

Overloads

UpdateRange(IEnumerable<TEntity>)

Begins tracking the given entities and entries reachable from the given entities using the Modified state by default, but see below for cases when a different state will be used.

UpdateRange(TEntity[])

Begins tracking the given entities and entries reachable from the given entities using the Modified state by default, but see below for cases when a different state will be used.

UpdateRange(IEnumerable<TEntity>)

Source:
DbSet%60.cs
Source:
DbSet%60.cs
Source:
DbSet.cs
Source:
DbSet.cs
Source:
DbSet.cs
Source:
DbSet.cs
Source:
DbSet.cs
Source:
DbSet.cs
Source:
DbSet.cs

Begins tracking the given entities and entries reachable from the given entities using the Modified state by default, but see below for cases when a different state will be used.

public virtual void UpdateRange (System.Collections.Generic.IEnumerable<TEntity> entities);
abstract member UpdateRange : seq<'Entity (requires 'Entity : null)> -> unit
override this.UpdateRange : seq<'Entity (requires 'Entity : null)> -> unit
Public Overridable Sub UpdateRange (entities As IEnumerable(Of TEntity))

Parameters

entities
IEnumerable<TEntity>

The entities to update.

Remarks

Generally, no database interaction will be performed until SaveChanges() is called.

A recursive search of the navigation properties will be performed to find reachable entities that are not already being tracked by the context. All entities found will be tracked by the context.

For entity types with generated keys if an entity has its primary key value set then it will be tracked in the Modified state. If the primary key value is not set then it will be tracked in the Added state. This helps ensure new entities will be inserted, while existing entities will be updated. An entity is considered to have its primary key value set if the primary key property is set to anything other than the CLR default for the property type.

For entity types without generated keys, the state set is always Modified.

Use State to set the state of only a single entity.

See EF Core change tracking and Using AddRange, UpdateRange, AttachRange, and RemoveRange for more information and examples.

Applies to

UpdateRange(TEntity[])

Source:
DbSet%60.cs
Source:
DbSet%60.cs
Source:
DbSet.cs
Source:
DbSet.cs
Source:
DbSet.cs
Source:
DbSet.cs
Source:
DbSet.cs
Source:
DbSet.cs
Source:
DbSet.cs

Begins tracking the given entities and entries reachable from the given entities using the Modified state by default, but see below for cases when a different state will be used.

public virtual void UpdateRange (params TEntity[] entities);
abstract member UpdateRange : 'Entity[] -> unit
override this.UpdateRange : 'Entity[] -> unit
Public Overridable Sub UpdateRange (ParamArray entities As TEntity())

Parameters

entities
TEntity[]

The entities to update.

Remarks

Generally, no database interaction will be performed until SaveChanges() is called.

A recursive search of the navigation properties will be performed to find reachable entities that are not already being tracked by the context. All entities found will be tracked by the context.

For entity types with generated keys if an entity has its primary key value set then it will be tracked in the Modified state. If the primary key value is not set then it will be tracked in the Added state. This helps ensure new entities will be inserted, while existing entities will be updated. An entity is considered to have its primary key value set if the primary key property is set to anything other than the CLR default for the property type.

For entity types without generated keys, the state set is always Modified.

Use State to set the state of only a single entity.

See EF Core change tracking and Using AddRange, UpdateRange, AttachRange, and RemoveRange for more information and examples.

Applies to