IDbSetExtensions.AddOrUpdate Method
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Overloads
AddOrUpdate<TEntity>(IDbSet<TEntity>, TEntity[]) |
Adds or updates entities by key when SaveChanges is called. Equivalent to an "upsert" operation from database terminology. This method can useful when seeding data using Migrations. |
AddOrUpdate<TEntity>(IDbSet<TEntity>, Expression<Func<TEntity,Object>>, TEntity[]) |
Adds or updates entities by a custom identification expression when SaveChanges is called. Equivalent to an "upsert" operation from database terminology. This method can useful when seeding data using Migrations. |
AddOrUpdate<TEntity>(IDbSet<TEntity>, TEntity[])
Adds or updates entities by key when SaveChanges is called. Equivalent to an "upsert" operation from database terminology. This method can useful when seeding data using Migrations.
public static void AddOrUpdate<TEntity> (this System.Data.Entity.IDbSet<TEntity> set, params TEntity[] entities) where TEntity : class;
static member AddOrUpdate : System.Data.Entity.IDbSet<'Entity (requires 'Entity : null)> * 'Entity[] -> unit (requires 'Entity : null)
<Extension()>
Public Sub AddOrUpdate(Of TEntity As Class) (set As IDbSet(Of TEntity), ParamArray entities As TEntity())
Type Parameters
- TEntity
Parameters
- set
- IDbSet<TEntity>
- entities
- TEntity[]
The entities to add or update.
Remarks
When the parameter is a custom or fake IDbSet implementation, this method will attempt to locate and invoke a public, instance method with the same signature as this extension method.
Applies to
AddOrUpdate<TEntity>(IDbSet<TEntity>, Expression<Func<TEntity,Object>>, TEntity[])
Adds or updates entities by a custom identification expression when SaveChanges is called. Equivalent to an "upsert" operation from database terminology. This method can useful when seeding data using Migrations.
public static void AddOrUpdate<TEntity> (this System.Data.Entity.IDbSet<TEntity> set, System.Linq.Expressions.Expression<Func<TEntity,object>> identifierExpression, params TEntity[] entities) where TEntity : class;
static member AddOrUpdate : System.Data.Entity.IDbSet<'Entity (requires 'Entity : null)> * System.Linq.Expressions.Expression<Func<'Entity, obj>> * 'Entity[] -> unit (requires 'Entity : null)
<Extension()>
Public Sub AddOrUpdate(Of TEntity As Class) (set As IDbSet(Of TEntity), identifierExpression As Expression(Of Func(Of TEntity, Object)), ParamArray entities As TEntity())
Type Parameters
- TEntity
Parameters
- set
- IDbSet<TEntity>
- identifierExpression
- Expression<Func<TEntity,Object>>
An expression specifying the properties that should be used when determining whether an Add or Update operation should be performed.
- entities
- TEntity[]
The entities to add or update.
Remarks
When the parameter is a custom or fake IDbSet implementation, this method will attempt to locate and invoke a public, instance method with the same signature as this extension method.
Applies to
Entity Framework