架构:简单的 CQS [英] Architecture: simple CQS

查看:24
本文介绍了架构:简单的 CQS的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在考虑为我的 ASP.NET MVC 网站应用 CQS,但这是一件非常简单的事情.我不是指 CQRS,因为我想对查询和命令部分使用相同的数据源,所以我不需要事件溯源和其他更复杂的模式.

I'm thinking about applying CQS for my ASP.NET MVC web site, but in a very simple matter. I don't mean CQRS, because I want to use the same data source for query and command parts, and so I don't need event sourcing and other more complex patterns.

所以,我的想法是:

  • 查询和命令部分使用同一个数据库
  • 对于查询部分,通过实体框架和WCF数据服务暴露数据库视图,让具体的视图返回给客户端,查询数据变得非常容易
  • 对于命令部分,使用实体框架和单向WCF服务公开数据库表,并使用DDD原则.

我要实现的主要目标是:

The main thing I want to achieve is:

  • 由单向服务操作执行并由富域模型处理的简单命令,客户端只需要传递执行命令真正需要的数据
  • 针对简单视图的灵活查询,专为客户端的特定 UI 而设计

这有意义吗?

推荐答案

所以,回答你的问题,是的,我认为这是有道理的.

So, to answer your question, yes I think it makes sense.

我不确定您还在寻找什么.我认为您采用的方法是有道理的,应该可以满足您的需求.

I'm not sure what else you're looking for. I think the approach you're taking makes sense and should give you what you are looking to do.

在我看来,CQS 和 CQRS 非常相似,其中 CQRS 具有单独的读写存储的概念(有些人会认为甚至可能不需要写入存储).事件溯源并不是 CQRS 的真正组成部分 - 可以说,它是一个附加组件,非常适合 CQRS 的分布式特性.

In my opinion, CQS and CQRS are very similar, where CQRS has the concept of separate read and write stores (and some would argue that the write store may not even be necessary). Event sourcing isn't really part of CQRS - it's an add-on, so to speak, that fits in nicely with the distributed nature of CQRS.

您放弃的方法是数据的一些可扩展性,因为您使用视图来展平数据.但是,如果您的应用不需要它,那么那里没有问题.

What you're giving up with your approach is some of the scalability of the data since you're flattening the data using views. But if your app doesn't require it, then there's no problem there.

此外,阅读 Udi Dahan 的 文章可能会很有用 关于何时避免 CQRS.它可能有助于证明你的决定是正确的.当他放开它时,引起了不小的轰动.但在他和 Greg Young 之间,他们是 CQRS 方面的专家.

Also, it may be useful to read Udi Dahan's article on when to avoid CQRS. It probably helps justify your decisions. It caused quite a stir when he released it. But between him and Greg Young, they're the experts on CQRS.

我不确定我是否回答了您的问题或提供了帮助,但祝您项目顺利!我希望这会有所帮助.

I'm not sure if I answered your question or helped, but good luck with your project! I hope this helps.

这篇关于架构:简单的 CQS的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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