如果存储库实现的UnitOfWork?UnitOfWork

2023-09-03 20:44:53 作者:许多愁

在一个DDD模式应该工作的单位要加上库?我见过几个不同的例子,包括一个仓库,实现工作界面的单元,实​​现了单位工作本身的行为资料库,并有一个属性重新presenting工作的单位,这样一个资料库,能够可以在UOW的寿命在多个储存库实例共享。在后一种情况下,它看起来有点像一个反模式......也就是说,要消费者真正需要知道的跨库实例共享UOW的实例?不应认为被包封并且不暴露给消费者?

In a DDD pattern should the unit of work be coupled with the repository? I've seen several different examples, including a repository that implements a unit of work interface, a repository that implements the behavior for unit of work itself, and a repository that has a property representing the unit of work so that it can be shared across multiple repository instances in the lifetime of the UoW. In the case of the latter, it kind of seems like an anti-pattern...that is, should a consumer really need to know to share an instance of UoW across repository instances? Shouldn't that be encapsulated and not exposed to the consumer?

我想听到一些意见对这些不同的方法的优势超过对方,为什么。

I'd like to hear some input on the advantages of these different approaches over each other and why.

感谢。

推荐答案

有一个讨论的这一点。

和我个人agree该UOW应该完全避免。同样的,通用的存储库。

And I personally agree that UoW should be avoided completely. Same with generic repositories.

 
精彩推荐
图片推荐