File tree 2 files changed +42
-40
lines changed
BasicClean.Infrastructure/Repository
2 files changed +42
-40
lines changed Original file line number Diff line number Diff line change
1
+ namespace BasicClean . Infrastructure . Repository
2
+ {
3
+ internal class EFQueryRepository < T , TKey > : IQueryRepository < T , TKey > where T : BaseEntity < TKey >
4
+ {
5
+ readonly TodoDbContext _context ;
6
+ public EFQueryRepository ( TodoDbContext todoDbContext )
7
+ {
8
+ _context = todoDbContext ;
9
+ }
10
+ public T Get ( Expression < Func < T , bool > > match )
11
+ {
12
+ return _context . Set < T > ( ) . FirstOrDefault ( match ) ;
13
+ }
14
+
15
+ public IEnumerable < T > GetAll ( )
16
+ {
17
+ return _context . Set < T > ( ) . ToList ( ) ;
18
+ }
19
+
20
+ public IEnumerable < T > GetAll ( Expression < Func < T , bool > > predicate )
21
+ {
22
+ return _context . Set < T > ( )
23
+ . Where ( predicate ) . ToList ( ) ;
24
+ }
25
+
26
+ public async Task < IEnumerable < T > > GetAllAsync ( )
27
+ {
28
+ return await _context . Set < T > ( ) . ToListAsync ( ) ;
29
+ }
30
+
31
+ public async Task < IEnumerable < T > > GetAllAsync ( Expression < Func < T , bool > > predicate )
32
+ {
33
+ return await _context . Set < T > ( )
34
+ . Where ( predicate ) . ToListAsync ( ) ;
35
+ }
36
+
37
+ public async Task < T > GetAsync ( Expression < Func < T , bool > > match )
38
+ {
39
+ return await _context . Set < T > ( ) . Where ( match ) . FirstOrDefaultAsync ( ) ;
40
+ }
41
+ }
42
+ }
Original file line number Diff line number Diff line change @@ -58,44 +58,4 @@ public async Task UpdateAsync(T entity)
58
58
await _context . SaveChangesAsync ( ) ;
59
59
}
60
60
}
61
-
62
- internal class EFQueryRepository < T , TKey > : IQueryRepository < T , TKey > where T : BaseEntity < TKey >
63
- {
64
- readonly TodoDbContext _context ;
65
- public EFQueryRepository ( TodoDbContext todoDbContext )
66
- {
67
- _context = todoDbContext ;
68
- }
69
- public T Get ( Expression < Func < T , bool > > match )
70
- {
71
- return _context . Set < T > ( ) . FirstOrDefault ( match ) ;
72
- }
73
-
74
- public IEnumerable < T > GetAll ( )
75
- {
76
- return _context . Set < T > ( ) . ToList ( ) ;
77
- }
78
-
79
- public IEnumerable < T > GetAll ( Expression < Func < T , bool > > predicate )
80
- {
81
- return _context . Set < T > ( )
82
- . Where ( predicate ) . ToList ( ) ;
83
- }
84
-
85
- public async Task < IEnumerable < T > > GetAllAsync ( )
86
- {
87
- return await _context . Set < T > ( ) . ToListAsync ( ) ;
88
- }
89
-
90
- public async Task < IEnumerable < T > > GetAllAsync ( Expression < Func < T , bool > > predicate )
91
- {
92
- return await _context . Set < T > ( )
93
- . Where ( predicate ) . ToListAsync ( ) ;
94
- }
95
-
96
- public async Task < T > GetAsync ( Expression < Func < T , bool > > match )
97
- {
98
- return await _context . Set < T > ( ) . Where ( match ) . FirstOrDefaultAsync ( ) ;
99
- }
100
- }
101
61
}
You can’t perform that action at this time.
0 commit comments