- 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
- Articles
- Troubleshooting
- Release Notes
Entity Framework Extensions Column Synchronize DeleteKey Subset Expression
Description
The ColumnSynchronizeDeleteKeySubsetExpression
allows you to synchronize (insert/update/delete) only a part of the tables by specifying a key.
The following example synchronizes customers of Type
equal to "1" by specifying the customer name as a key.
var customers = new List<Customer>(); customers.Add(new Customer() { Name = "Carson", Type = 1, Description = "Updated_Description of Carson", IsActive = false }); customers.Add(new Customer() { Name = "Alexander", Type = 1, Description = "Description of Alexander", IsActive = false }); using (var context = new EntityContext()) { context.BulkSynchronize(customers, options => { options.ColumnPrimaryKeyExpression = customer => customer.Name; options.ColumnSynchronizeDeleteKeySubsetExpression = customer => customer.Type; }); }
A synchronize is a mirror operation from the data source to the database. All rows that match the entity key are UPDATED
, non-matching rows that exist from the source are INSERTED
, non-matching rows that exist in the database are DELETED
.
- It updates the record of Carson as it is already in the database
- It inserts Alexander record because it is not available in the database.
- It will also delete any other customers available in the database of Type "1" which are not available in the source (
customers
list).
Author: ZZZ Projects