如果存储库实现的UnitOfWork? [英] Should a Repository implement UnitOfWork?

查看:137
本文介绍了如果存储库实现的UnitOfWork?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在一个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.

感谢。

推荐答案

有一个讨论的这一点。

和我个人<一个href="http://stackoverflow.com/questions/4007145/ddd-architecture-for-asp-net-mvc2-project/4013152#4013152">agree该UOW应该完全避免。同样的,通用的存储库。

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

这篇关于如果存储库实现的UnitOfWork?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆