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*

9
  • Yes I understand the concept of using more than one DB tables (entities) and tracking all of them with a single source. That's why I came up with my second code block. Isn't it the same? If it is the same, if I can reach the same goal without using UOW why should I use it? In the second code block I also use more than one entities and I can save changes with the shared DBContext. So I think it will produce the same result with UOW. So there are two questions. 1- Am I incorrect, Doesn't the second code block yield the same result with UOW. 2- If it is the same what is the extra benefit of UOW. Commented Mar 19, 2020 at 6:43
  • Can you explain why one needs an additional unit-of-work pattern when entity Framework context already implements the very behaviors you describe? Commented Mar 19, 2020 at 6:44
  • @Mansur: in which class do you want to place your "second code block"? Commented Mar 19, 2020 at 7:02
  • 1
    @nvoigt: ok, I added a few words. To what you wrote about "people" here: the idea should be that one starts to implement a certain use case, and when the transactional handling of the objects involved becomes obviously too complex, then it is time to refactor the complexity into a separate layer like the UoW. The UoW is not for people who work like braindead zombies and try to throw patterns at a system "just in case" - one has to see the problem in code first, and then solve it, not the other way round. Commented Mar 19, 2020 at 8:16
  • 2
    @DocBrown I absolutely agree with that. Commented Mar 19, 2020 at 8:20