Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

5
  • can you add an example of how your idea would work? Commented Oct 9, 2021 at 12:19
  • @Ewan I've edited my question Commented Oct 9, 2021 at 12:45
  • 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. Commented Oct 9, 2021 at 14:40
  • 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 Commented Oct 9, 2021 at 22:49
  • ... 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 Commented Oct 9, 2021 at 22:49