- 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 Bulk Options
Entity Framework Extensions have been created to be fast but also to be extensible, with hundreds of options available. Understanding available options is essential to make your Bulk Extensions more flexible, but also to know how to pass them:
Fluent API Options
Passing options through a fluent API is recommended in Entity Framework Extensions. This technique is simple and matches the way you write your LINQ syntax.
You can pass 1 option by directly setting it or use braces to pass multiple options, such as
// only work with 1 option context.BulkInsert(invoices, options => options.IncludeGraph = true); // work with multiple options context.BulkInsert(invoices, options => { options.IncludeGraph = true }); context.BulkInsert(invoices, options => { options.IncludeGraph = true; options.BatchTimeout = 180; });
BulkOperationOptions Variable
Starting from v8.101.0, you can now pass options by creating a new Z.BulkOperations.BulkOperationOptions
instance.
You can either choose to:
- From a DbSet
- Creating an instance with a generic type
- Creating an instance without a generic type
// CREATE bulkOptions instance var bulkOptions = context.Invoices.CreateBulkOptions(); var bulkOptions_Generic = new Z.BulkOperations.BulkOperationOptions<Invoice>(); var bulkOptions_NonGeneric = new Z.BulkOperations.BulkOperationOptions(); // SET Options bulkOptions.IncludeGraph = true; bulkOptions.BatchTimeout = 180; // CALL a bulk method context.BulkInsert(invoices, bulkOptions);
Conclusion
Whether you pass options with a fluent API or through a BulkOperationOptions
variable is a personal choice. Both techniques are now supported, and sometimes, a technique might be more appropriate than another one, but by default, we recommend sticking with only one in your code.
Author: ZZZ Projects