Skip to content

Commit 3ec90ea

Browse files
Merge pull request #468 from Lempireqc/patch-1
Update tutorial-batch-operations.md
2 parents 76e2d4b + a13ca56 commit 3ec90ea

File tree

1 file changed

+11
-6
lines changed

1 file changed

+11
-6
lines changed

docs2/pages/getting-started/tutorial-batch-operations.md

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,18 @@ Deletes multiples rows in a single database roundtrip and without loading entiti
88
```csharp
99
// using Z.EntityFramework.Plus; // Don't forget to include this.
1010
11-
// DELETE all users which has been inactive for 2 years
12-
ctx.Users.Where(x => x.LastLoginDate < DateTime.Now.AddYears(-2))
11+
// DELETE all users inactive for 2 years
12+
var date = DateTime.Now.AddYears(-2);
13+
ctx.Users.Where(x => x.LastLoginDate < date)
1314
.Delete();
1415

1516
// DELETE using a BatchSize
16-
ctx.Users.Where(x => x.LastLoginDate < DateTime.Now.AddYears(-2))
17+
var date = DateTime.Now.AddYears(-2);
18+
ctx.Users.Where(x => x.LastLoginDate < date)
1719
.Delete(x => x.BatchSize = 1000);
1820

1921
```
22+
{% include component-try-it.html href='https://dotnetfiddle.net/asjI4U' %}
2023

2124
***Support:** EF5, EF6, EF Core*
2225

@@ -30,12 +33,14 @@ Updates multiples rows using an expression in a single database roundtrip and wi
3033
```csharp
3134
// using Z.EntityFramework.Plus; // Don't forget to include this.
3235
33-
// UPDATE all users which has been inactive for 2 years
34-
ctx.Users.Where(x => x.LastLoginDate < DateTime.Now.AddYears(-2))
36+
// UPDATE all users inactive for 2 years
37+
var date = DateTime.Now.AddYears(-2);
38+
ctx.Users.Where(x => x.LastLoginDate < date)
3539
.Update(x => new User() { IsSoftDeleted = 1 });
3640

3741
```
42+
{% include component-try-it.html href='https://dotnetfiddle.net/cV3IHD' %}
3843

3944
***Support:** EF5, EF6, EF Core*
4045

41-
[Learn more](/batch-update)
46+
[Learn more](/batch-update)

0 commit comments

Comments
 (0)