- Main Features
-
Bulk Options
- Bulk Options
- Audit
- Batch
-
Column
- Column Input Expression
- Column Output Expression
- Column InputOutput Expression
- Column PrimaryKey Expression
- Column Synchronize DeleteKey Subset Expression
- Ignore OnInsert Expression
- Ignore OnMergeInsert Expression
- Ignore OnMergeMatched AndCondition Expression
- Ignore OnMergeMatched AndOneNotCondition Expression
- Ignore OnMergeUpdate Expression
- Ignore OnSynchronizeInsert Expression
- Ignore OnSynchronizeMatched AndCondition Expression
- Ignore OnSynchronizeMatched AndOneNotCondition Expression
- Ignore OnSynchronizeUpdate Expression
- Ignore OnUpdate Expression
- Ignore OnUpdateMatched AndCondition Expression
- Ignore OnUpdateMatched AndOneNotCondition Expression
- MergeMatched AndCondition Expression
- MergeMatched AndNotCondition Expression
- SynchronizeMatched AndCondition Expression
- SynchronizeMatched AndOneNotCondition Expression
- UpdateMatched AndCondition Expression
- UpdateMatched AndOneNotCondition Expression
- Coalesce Destination OnMergeUpdate Expression
- Coalesce Destination OnUpdate Expression
- Coalesce OnMergeUpdate Expression
- Coalesce OnUpdate Expression
- Context Factory
- Execute Event
- ExplicitValueResolutionMode
- Identity
- Include Graph
- ForceValueGeneratedStrategy
- Key
- Logging
- Rows Affected
- Temporary Table
- Transaction
- Transient Error
- SQL Server
- Coalesce
- Coalesce Destination
- Delete Matched and Condition
- Delete Matched and one NOT Condition
- Delete Matched and Formula
- Matched and Condition
- Matched and one NOT Condition
- Matched and Formula
- Batch Operations
- Events
- Utilities
- C# Eval Expression
30% OFF - 10th Anniversary discount on new purchases until December 15 with code: ZZZANNIVERSARY10
Entity Framework Extensions AllowDuplicateKeys
Description
The BulkOperation.AuditEntries
property gets or sets if a duplicate key is possible in the source.
The following example chooses a Name
property as a key to perform the BulkMerge
operations and also allows a duplicate key.
var list = new List<Customer>() { new Customer() { Name = "Customer_A", Description = "Description_updated" }, new Customer() { Name ="Customer_B", Description = "Description"} }; using (var context = new EntityContext()) { context.BulkMerge(list,options => { options.ColumnPrimaryKeyExpression = customer => customer.Name; options.AllowDuplicateKeys = true; }); }
- It will update the record of "Customer_A" because it already exists in the database.
- The data for "Customer_B" is inserted to the database as a new record.
Purpose
In a rare scenario such as importing a file, a key may be used in multiple rows.
In some provider such as SQL Server, the statement created by our library (Merge
) makes it impossible to use with some duplicate keys.
By enabling this option, only the latest key is used instead.
Author: ZZZ Projects