汇总一个实体 [英] Aggregate for one entity

查看:85
本文介绍了汇总一个实体的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在域驱动的设计中,如果我想使用存储库,则需要为其汇总-据我所知。

In Domain-driven design if I want to use a repository I need to have an aggregate for it - as I understand.

所以我有一个用户,该用户具有ID,登录名,电子邮件和密码。用户是具有唯一ID的域实体。

So I have a User, that has id, login, email, and password. A user is a domain Entity with unique Id.

当我想向用户存储库中添加用户时,我应该首先构建一个仅包含我的用户的聚合根的聚合实体,仅此而已?在这种情况下,它看起来像是User的代理,不需要的层。

When i want to add a User to User repository, should I build first an Aggregate with only Aggregate Root that is my User entity and nothing more? It looks like a proxy to User in this case, unneeded layer.

还是我错过了这里的东西?也许用户不是一个实体,即使它看起来像这样。也许我可以直接将实体放置到存储库中?

Or maybe I missed something here? Maybe User isnt an Entity, even if it looks like this. Or maybe I can put an Entity directly to repository?

推荐答案

聚合根(AR)是实体,并且拥有作为其自身集合根的实体是很常见的。

An aggregate root (AR) is an entity and it's very common to have entities which are the root of their own aggregate.

您的 User 实体会只需成为聚合根即可。您不需要额外的具体课程。

Your User entity would simply be an aggregate root. You do not need an extra concrete class.

这篇关于汇总一个实体的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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