Skip to content

Commit dc93f6f

Browse files
Example for partial updates and info about permissions
1 parent baa5781 commit dc93f6f

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

README.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,18 @@ On my dev machine that runs at around 153ms instead of 6s using the 'out of the
194194

195195
SqlBulkCopy is used under the covers if you are running against SqlServer. If you are not running against SqlServer it will default to doing the normal inserts.
196196

197+
#### Partial updates / Not loading the data from DB first
198+
199+
Because you specify which columns to update you can do simple partial updates. In the example above I could have generated the list ```commentsFromDb``` from an import file for example. What I need to populate is the PrimaryKey and the columns I specify to update.
200+
201+
Example:
202+
203+
```c#
204+
var lines = csv.ReadAllLines().Select(l => l.Split(";"));
205+
var comments = lines.Select(line => new Comment{ Id = int.Parse(line[0]), Reads = int.Parse(line[1]) });
206+
EFBatchOperation.For(db, db.Comments).UpdateAll(comments, x => x.ColumnsToUpdate(c => c.Reads));
207+
```
208+
197209
#### Inheritance and Bulk insert
198210

199211
Not tested but most likely TPH will work as the code is very similar to InsertAll
@@ -207,6 +219,10 @@ If your best choice is using TransactionScope. See example here https://github.c
207219
Profilers like MiniProfilers wrap the connection. EFUtilities need a "pure" connection.
208220
One of the arguments is a connection that you can supply.
209221

222+
#### Permissions
223+
224+
The SQL Server provider creates a temporary template. The login you are using must have permissions to create and drop a table.
225+
210226
### Update by query
211227

212228

0 commit comments

Comments
 (0)