实体框架和预先加载和企业应用程序与DDD的aproach [英] Entity framework and Eager loading and enterprise application with DDD aproach

查看:250
本文介绍了实体框架和预先加载和企业应用程序与DDD的aproach的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

ITNOA

我们正努力创造使用实体框架,领域驱动开发风格模式方法的ASP.NET MVC应用4。正如你可以在我们的领域层的部分看到的,我们有一个复杂的设计。我们需要懒散以及渴望方法来加载实体。不幸的是,我们有实体框架这些方法的大问题。

据我们了解,在EF预先加载,我们必须使用包含方法,让性能和性能等特性的字符串(在Hibernate和Java我们可以使用成员的注释顶部急切地加载和它比这种做法容易得多)。但可怕的问题是,我们必须继承结构,重多态性,在这些国家,我们没有这是我们应该考虑到包括因为我们不知道类类的选择,了解哪些属性应该包括。它派生的字符串

例如,你可以看到一个结果具有项目的集合,然后决定将一些组添加到这个集合每个小组有一定的群体和领域(如构图模式)。现在想象一下,我们要加载的结果就像是一个上面谈到。当我想要写的给定一串包括,我不知道这是什么结果,项目组。因为我们不能predict这些项目组,因此这些团体项目的收集应加载。

  this.Items =新的List<项目>
            {
                新集团(
                    一个,
                    新的List<项目>
                    {
                        新场(B),
                        新场(C)
                        新的字段(D)

最后,我们有一个关键的问题:是专为企业应用程序具有复杂域和DDD的做法实体框架?如果没有,我们如何遵循Martin Fowler的和埃里克·埃文斯在软件工程和C#中的方法企业级应用?


解决方案

  

是一款专为企业应用程序具有复杂域和DDD的做法实体框架?


一个真正的域模型可能有不同的形状,从原因有很多相应的数据模型。喜欢EF或NHibernate的企业的ORM的目标是要在两者之间翻译,甚至支持多个数据库的点

我真的不看是你的域模型。您的图看起来像一个数据模型,这是一个实现细节。我希望看到医生,病人,问卷调查,任用,待遇,prescription等,您可以选择将这些存储在你所描述的风格(StackOverflow上同时存储的问题和答案的帖子,例如),但是这什么映射是,如果您使用的是关系型数据库,你可能会更好具有类似于域模型的表是诚实的。如果你要为一个完全灵活的存储那么RDBMS可能是不正确的工具 - 考虑也许是一个文档数据库,而不是

ITNOA

We are trying to create an ASP.NET MVC 4 application using entity framework with domain driven development style pattern approach. As you can see in our part of domain layer, we have a complex design. We need to load entity with lazy as well as eager methods. Unfortunately we have big problem with these methods in entity framework.

As we understand, for eager loading in EF we have to use the Include method and give string of properties and properties of properties etc. (In Hibernate and java we could use annotation top of member to load eagerly and it was so much easier than this approach). But the horrible problem is that we have inheritance structures and heavy polymorphism, in these states we don’t have that’s string we should given to include because we don’t know which derived class of class is selected to understand which properties should include.

For example as you can see a result has a collection of items and then decides to add some group to this collection and each of those groups have some groups and fields (like the composition pattern). Now imagine we want to load a result is like the one talked above. When I want to write a string of given include I don’t know what items of this result are groups. Because we can’t predict these items are groups and so these groups have collection of items which should load.

this.Items = new List<Item> 
            {
                new Group(
                    a,
                    new List<Item>
                    { 
                        new Field(b),
                        new Field(c),
                        new Field(d),

At last we have a critical question: is entity framework designed for Enterprise Applications with a complex domain and DDD approach? If not, how we follow the approach of Martin Fowler and Eric Evans in software engineering and enterprise application in C#?

解决方案

is entity framework designed for Enterprise Applications with a complex domain and DDD approach?

Yes.

A real domain model may differ in shape from the corresponding data model for many reasons. The goal of an "enterprise" ORM like EF or NHibernate is to translate between the two, even to the point of supporting multiple databases.

What I don't really see is your domain model. Your diagram looks like a data model, which is an implementation detail. I'd expect to see Doctor, Patient, Questionnaire, Appointment, Treatment, Prescription etc. You may choose to store these in the style you describe (StackOverflow stores both questions and answers as "Posts", for example) but that's what the mapping is for, and to be honest if you're using a relational database you might be better off having tables that are similar to the domain model. If you're going for a totally flexible storage then an RDBMS is probably not the right tool - consider perhaps a document database instead?

这篇关于实体框架和预先加载和企业应用程序与DDD的aproach的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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