Skip to content

Commit 888cedb

Browse files
authored
Update README.md
1 parent e2b987d commit 888cedb

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,7 @@ context.BulkInsertOrUpdate(entities, new BulkConfig { SetOutputIdentity = true }
259259
context.BulkInsertOrUpdate(entities, b => b.SetOutputIdentity = true); //BulkConfig with Action arg.
260260
```
261261

262-
**PreserveInsertOrder** is **true** by default and makes sure that entities are inserted to Db as ordered in entitiesList.
262+
**(1) PreserveInsertOrder** is **true** by default and makes sure that entities are inserted to Db as ordered in entitiesList.
263263
When a table has Identity column (int autoincrement) with 0 values in list, they will temporarily be automatically changed from 0s into range -N:-1.
264264
Or it can be manually set with proper values for order (Negative values used to skip conflict with existing ones in Db).
265265
Here single Id value itself doesn't matter, db will change it to next in sequence, what matters is their mutual relationship for sorting.
@@ -269,12 +269,12 @@ When using **SetOutputIdentity** Id values will be updated to new ones from data
269269
With BulkInsertOrUpdate on SQLServer for those that will be updated it has to match with Id column, or other unique column(s) if using UpdateByProperties in which case [orderBy done with those props](https://github.com/borisdj/EFCore.BulkExtensions/issues/806) instead of ID, due to how Sql MERGE works. To preserve insert order by Id in this case alternative would be first to use BulkRead and find which records already exist, then split the list into 2 lists entitiesForUpdate and entitiesForInsert without configuring UpdateByProps).
270270
Also for SQLite combination of BulkInsertOrUpdate and IdentityId automatic set will not work properly since it does [not have full MERGE](https://github.com/borisdj/EFCore.BulkExtensions/issues/556) capabilities like SqlServer. Instead list can be split into 2 lists, and call separately BulkInsert and BulkUpdate.
271271

272-
**SetOutputIdentity** is useful when BulkInsert is done to multiple related tables that have Identity column.
272+
**(2) SetOutputIdentity** is useful when BulkInsert is done to multiple related tables that have Identity column.
273273
After Insert is done to the first table, we need Id-s (if using Option 1) that were generated in Db because they are FK(ForeignKey) in second table.
274274
It is implemented with [OUTPUT](https://docs.microsoft.com/en-us/sql/t-sql/queries/output-clause-transact-sql) as part of MERGE Query, so in this case, even the Insert is not done directly to TargetTable but to TempTable and then Merged with TargetTable.
275275
When used Id-s will be updated on entitiesList, and if *PreserveInsertOrder* is set to *false* then entitiesList will be cleared and reloaded.
276276
If Entity has Json column with null value and we set OutputIdentity then also set OutputNonIdentity to false, because [JsonNull](https://github.com/borisdj/EFCore.BulkExtensions/issues/1572) mapping throws an exception.
277-
**SetOutputNonIdentityColumns** used only when *SetOutputIdentity* is set to true, and if this remains True (which is default) all columns are reloaded from Db.
277+
**(3) SetOutputNonIdentityColumns** used only when *SetOutputIdentity* is set to true, and if this remains True (which is default) all columns are reloaded from Db.
278278
When changed to false, only the Identity column is loaded to reduce load back from DB for efficiency.
279279

280280
Example of *SetOutputIdentity* with parent-child FK related tables:

0 commit comments

Comments
 (0)