Unit of Work pattern when there is no dbcontext

Viewed 2471

I've seen many implementations of this pattern, mostly with dbcontext. But I don't know (yet) whether I'll use a database in my project at all.

Are there other ways to implement this pattern without hand-roll all the code to track changes of the entity objects?

1 Answers

There are, of course. Though those are much harder. Having a singe proxy, accumulating all the changes done till the very last moment is easier to code and maintain. The other natural option would be to proxy your concrete DTO's or models, or entities, or what-is-the-name-of-that-thingy-you-are-using-in-your-project. And yet another other way is to extract mutations into kinda Patches and apply them as soon as needed (lazy fashion). There are numerous other ways as well.

However... if you won't have a DB at all, why the heck you need unit of work?! What's the benefit?!

Related