域驱动设计中哪些对象应包含数据库访问方法 [英] Which objects should contain the database access methods in domain driven design

查看:69
本文介绍了域驱动设计中哪些对象应包含数据库访问方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我以为域驱动设计是说Get方法在存储库中,而Add/Del/Update在业务对象中?

I thought domain driven design is saying the Get-methods are in the Repositories and the Add/Del/Update are in the business objects?

请您澄清一下吗?

当我查看MVCMusicStore样本时,数据库的所有CRUD方法都在实体中?!

When I look at the MVCMusicStore sample all CRUD methods to the database are in the entities ?!

http://mvcmusicstore.codeplex.com/SourceControl/changeset/view/d9f25c5263ed#MvcMusicStore%2fModels%2fShoppingCart.cs

推荐答案

您发布的链接不是域驱动设计的示例,它只是说明了MVC模式.如您所述,实体包含所有持久性逻辑,而业务逻辑主要位于控制器中.

The link you posted isn't an example of domain-driven design, it simply illustrates the MVC pattern. As you mentioned, the entities contain all persistence logic while the business logic lies primarily in the controllers.

在同一系统的域驱动设计中,实体将包含任何持久性逻辑,但它们包含大多数业务逻辑.所有的持久性功能都将驻留在存储库中,并且控制器(也称为服务)将非常薄,并将大部分工作委托给实体.

In a domain-driven design of the same system, entities would not contain any persistence logic but they would contain most of the business logic. All persistence functions would reside in repositories, and the controllers (a.k.a. services) would be extremely thin and delegate most of the work to entities.

这篇关于域驱动设计中哪些对象应包含数据库访问方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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