File tree Expand file tree Collapse file tree 3 files changed +25
-0
lines changed
LibraryManagement.Api/Brokers/Storages Expand file tree Collapse file tree 3 files changed +25
-0
lines changed Original file line number Diff line number Diff line change @@ -10,5 +10,7 @@ namespace LibraryManagement.Api.Brokers.Storages
1010 public partial interface IStorageBroker
1111 {
1212 ValueTask < Book > InsertBookAsync ( Book book ) ;
13+ IQueryable < Book > SelectAllBooks ( ) ;
14+ ValueTask < Book > SelectBookByIdAsync ( Guid bookId ) ;
1315 }
1416}
Original file line number Diff line number Diff line change @@ -14,5 +14,21 @@ public partial class StorageBroker
1414
1515 public async ValueTask < Book > InsertBookAsync ( Book book ) =>
1616 await InsertAsync ( book ) ;
17+
18+ public IQueryable < Book > SelectAllBooks ( )
19+ {
20+ var books = SelectAll < Book > ( ) . Include ( a => a . Reader ) ;
21+
22+ return books ;
23+ }
24+
25+ public async ValueTask < Book > SelectBookByIdAsync ( Guid bookId )
26+ {
27+ var readerWithBooks = Books
28+ . Include ( a => a . Reader )
29+ . FirstOrDefault ( a => a . BookId == bookId ) ;
30+
31+ return await ValueTask . FromResult ( readerWithBooks ) ;
32+ }
1733 }
1834}
Original file line number Diff line number Diff line change @@ -27,6 +27,13 @@ public async ValueTask<T> InsertAsync<T>(T @object)
2727 return @object ;
2828 }
2929
30+ public IQueryable < T > SelectAll < T > ( ) where T : class
31+ {
32+ var broker = new StorageBroker ( configuration ) ;
33+
34+ return broker . Set < T > ( ) ;
35+ }
36+
3037 protected override void OnConfiguring ( DbContextOptionsBuilder optionsBuilder )
3138 {
3239 string connectionString =
You can’t perform that action at this time.
0 commit comments