@@ -8,16 +8,20 @@ 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```
2022
23+ {% include component-try-it.html href='https://dotnetfiddle.net/asjI4U ' %}
24+
2125*** Support:** EF5, EF6, EF Core*
2226
2327[ Learn more] ( /batch-delete )
@@ -30,12 +34,15 @@ Updates multiples rows using an expression in a single database roundtrip and wi
3034``` csharp
3135// using Z.EntityFramework.Plus; // Don't forget to include this.
3236
33- // UPDATE all users which has been inactive for 2 years
34- ctx .Users .Where (x => x .LastLoginDate < DateTime .Now .AddYears (- 2 ))
37+ // UPDATE all users inactive for 2 years
38+ var date = DateTime .Now .AddYears (- 2 );
39+ ctx .Users .Where (x => x .LastLoginDate < date )
3540 .Update (x => new User () { IsSoftDeleted = 1 });
3641
3742```
3843
44+ {% include component-try-it.html href='https://dotnetfiddle.net/cV3IHD ' %}
45+
3946*** Support:** EF5, EF6, EF Core*
4047
41- [ Learn more] ( /batch-update )
48+ [ Learn more] ( /batch-update )
0 commit comments