使用 Raven DB 的数据访问架构
我可以将哪些数据访问架构与 Raven DB 结合使用?
基本上,我想通过接口分离持久性,因此我不会将底层存储暴露给上层。即,我不希望我的域看到来自 Raven DB 的 IDocumentStore 或 IDocumentSession。
我已经实现了通用存储库模式,这似乎有效。但是,我不确定这实际上是正确的方法。也许我应该采取命令查询隔离或其他方式?
你有什么想法?
What data access architectures are available that I can use with Raven DB?
Basically, I want to separate persistence via interfaces, so I don't expose underline storage to the upper layers. I.e. I don't want my domain to see IDocumentStore or IDocumentSession which are from Raven DB.
I have implemented the generic repository pattern and that seems to work. However, I am not sure that is actually the correct approach. Maybe I shall go towards command-query segregation or something else?
What are your thoughts?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
就我个人而言,我对命令模式并没有真正的经验。我看到它被用在 Rob Ashton 的优秀教程中。
对于我自己来说,我将尝试使用以下内容: -
因此,当我希望从 RavenDB(持久性源)获取任何数据时,我将使用服务,然后它将调用适当的存储库,这样,我就不会将存储库暴露给应用程序 存储库非常重或复杂 -> 它基本上是一个 FindAll / Save / Delete
例如,
所以这是一个非常简单且人为的示例,没有错误/验证检查、try/catch 等......并且它是伪代码..但您可以看到服务如何丰富,而存储库(至少对我来说)简单或更轻然后。我只通过服务公开任何数据,
这就是我现在使用
.NET
和Entity Framework
所做的事情,距离尝试还差几个小时。 RavenDb(哇!)
Personally, I'm not really experienced with the Command Pattern. I saw that it was used in Rob Ashton's excellent tutorial.
For myself, I'm going to try using the following :-
So when i wish to get any data from RavenDB (the persistence source), i'll use Services, which will then call the appropriate repository. This way, i'm not exposing the repository to the Application nor is the repository very heavy or complex -> it's basically a FindAll / Save / Delete.
eg.
So that's a very simple and contrived example with no error/validation checking, try/catch, etc... .. and it's pseudo code .. but you can see how the services are rich while the repository is (suppose to be, for me at least) simple or lighter. And then I only expose any data via services.
That's what I do right now with
.NET
andEntity Framework
and I'm literally hours away from giving this a go withRavenDb
(WOOT!)你想通过这个达到什么目的?
您无法构建同时使用 RDBMS 和 DocDB 的应用程序,至少效率不高。您必须自己决定要使用哪个数据库,然后一直使用它。如果您决定使用 RDMBS,您可以使用 NHibernate,然后再说一次 - 不需要任何其他抽象层。
What are you trying to achieve by that?
You can't build an application which makes use of both an RDBMS and DocDB, not efficiently at least. You have to decide for yourself which database you are going to use, and then go all the way with it. If you decide to go with an RDMBS, you can use NHibernate for example, and then again - no need for any other abstraction layer.