File tree Expand file tree Collapse file tree 4 files changed +13
-6
lines changed
frameworks/CSharp/genhttp/Benchmarks/Tests Expand file tree Collapse file tree 4 files changed +13
-6
lines changed Original file line number Diff line number Diff line change 3
3
using System . Linq ;
4
4
using System . Threading . Tasks ;
5
5
6
+ using Microsoft . EntityFrameworkCore ;
7
+ using Microsoft . Extensions . Caching . Memory ;
8
+
6
9
using Benchmarks . Model ;
7
10
8
11
using GenHTTP . Modules . Webservices ;
9
12
10
- using Microsoft . Extensions . Caching . Memory ;
11
-
12
13
namespace Benchmarks . Tests
13
14
{
14
15
@@ -67,7 +68,7 @@ public async ValueTask<List<World>> GetWorlds(string queries)
67
68
}
68
69
else
69
70
{
70
- var resolved = await context . World . FindAsync ( id ) ;
71
+ var resolved = await context . World . FirstOrDefaultAsync ( w => w . Id == id ) ;
71
72
72
73
_Cache . Set ( key , resolved ) ;
73
74
Original file line number Diff line number Diff line change 1
1
using System ;
2
2
using System . Threading . Tasks ;
3
3
4
+ using Microsoft . EntityFrameworkCore ;
5
+
4
6
using GenHTTP . Modules . Webservices ;
5
7
6
8
using Benchmarks . Model ;
@@ -19,7 +21,7 @@ public async ValueTask<World> GetRandomWorld()
19
21
20
22
using var context = DatabaseContext . CreateNoTracking ( ) ;
21
23
22
- return await context . World . FindAsync ( id ) ;
24
+ return await context . World . FirstOrDefaultAsync ( w => w . Id == id ) ;
23
25
}
24
26
25
27
}
Original file line number Diff line number Diff line change 2
2
using System . Collections . Generic ;
3
3
using System . Threading . Tasks ;
4
4
5
+ using Microsoft . EntityFrameworkCore ;
6
+
5
7
using Benchmarks . Model ;
6
8
7
9
using GenHTTP . Modules . Webservices ;
@@ -34,7 +36,7 @@ public async ValueTask<List<World>> GetWorlds(string queries)
34
36
{
35
37
var id = _Random . Next ( 1 , 10001 ) ;
36
38
37
- result . Add ( await context . World . FindAsync ( id ) ) ;
39
+ result . Add ( await context . World . FirstOrDefaultAsync ( w => w . Id == id ) ) ;
38
40
}
39
41
40
42
return result ;
Original file line number Diff line number Diff line change 3
3
using System . Linq ;
4
4
using System . Threading . Tasks ;
5
5
6
+ using Microsoft . EntityFrameworkCore ;
7
+
6
8
using Benchmarks . Model ;
7
9
8
10
using GenHTTP . Modules . Webservices ;
@@ -35,7 +37,7 @@ public async ValueTask<List<World>> UpdateWorlds(string queries)
35
37
{
36
38
foreach ( var id in ids )
37
39
{
38
- var record = await context . World . FindAsync ( id ) ;
40
+ var record = await context . World . FirstOrDefaultAsync ( w => w . Id == id ) ;
39
41
40
42
var old = record . RandomNumber ;
41
43
You can’t perform that action at this time.
0 commit comments