Timeline for Is it a bad idea to save the database in middleware?
Current License: CC BY-SA 4.0
10 events
| when toggle format | what | by | license | comment | |
|---|---|---|---|---|---|
| Oct 11, 2021 at 11:21 | answer | added | Flater | timeline score: 0 | |
| Oct 9, 2021 at 22:49 | comment | added | Filip Milovanović |
... so that those callers (like your Services) don't have to deal with database stuff in their code (like grab related entities, or do joins, or initial filtering, and such). You can have a different repository for each service, and repo methods aren't generic CRUD operations, but methods very specific to the needs of the service (e.g. not GetBooks(), but something use-case specific, like GetBooksAwaitingCatalogization(), possibly with parameters; it's not supposed to be just a renaming of the DBContext API). These then call the same underlying database provider. 2/2
|
|
| Oct 9, 2021 at 22:49 | comment | added | Filip Milovanović | Don't have time for a full answer, but here are some pointers (so you can look things up). "Now I don't like the unit of work concept." - Unit of Work just tracks what props have changed in order to construct update queries; ORMs like EF already do this for you. "I read a blog [...] saying that is should act like a collection" - I think this comes from the notion of the Repository found in Eric Evans' DDD book, but there, the main point is not that it should act as a collection, but that it should look, to callers, like a database-agnostic collection (within reason), ... 1/2 | |
| Oct 9, 2021 at 19:34 | answer | added | Ewan | timeline score: 2 | |
| Oct 9, 2021 at 15:05 | answer | added | Kind Contributor | timeline score: 3 | |
| Oct 9, 2021 at 14:40 | comment | added | edalorzo | The unit of work pattern is already part of your entity framework. I don't think you need to do anything there. You deal with entities in memory, that's why you don't need any update in the repo. If you change an entity, it will be eventually flushed to disk by your unit of work within your entity framework. | |
| Oct 9, 2021 at 12:45 | comment | added | Roy Berris | @Ewan I've edited my question | |
| Oct 9, 2021 at 12:45 | history | edited | Roy Berris | CC BY-SA 4.0 |
Added information about how it would work
|
| Oct 9, 2021 at 12:19 | comment | added | Ewan | can you add an example of how your idea would work? | |
| Oct 9, 2021 at 11:21 | history | asked | Roy Berris | CC BY-SA 4.0 |