.NET ORM比较NET、ORM

2023-09-02 01:24:32 作者:子夏

我是说与某人有关的实体框架,我没有真正进入过,但我想了解它。不过,我还是有点迷茫,我是否应该学习与否。我听到很多人说你不应该使用实体framwork,但是我还没有heared任何参数这是为什么。

I was talking with someone about the Entity Framework, and I'm not really into it yet, but I'd like to learn it. However, I'm still kinda confused whether I should learn it or not. I've heard a lot of people saying you shouldn't use the entity framwork, however I haven't heared any arguments why that is.

所以我的问题是,什么是亲的和反对的使用实体框架compared其他产品的。像

So my question is, what are the pro's and con's of using the Entity Framework compared to other products. Like

NHibernate的 DataObjects.Net 等

在易用性方面,可测试性,语义...

In terms of ease of use, testability, semantics...

我知道有一些重复 questions关于这个。但他们都有点过时(2008,2009),老实说,参数也缺了点什么。我知道,实体框架4.0是可用的,而我还没有找到一个很好的(完整的)比较呢。

I know there are some duplicate questions about this. But they are all kinda outdated (2008,2009) and to be honest, the arguments are also lacking something. I know Entity Framework 4.0 is available, and I haven't found a good (complete) comparison yet.

一些漂亮的人在这里都被解释在不同的框架的一些细节回答我的问题。认为这可能是好他们在这里展示以供将来参考。

Some of the nice people here have answered my question by explaining some details on the different frameworks. Thought it might be good to show them here for future reference.

J.吉洪作出了外观极好文章,解释如何使EF工作的时候,你需要更多的可扩展性。 迭戈Mijelshon已经创造了一些EF的陷阱的答案和NHibernate如何解决它们。 J. Tihon has made an excelent post explaining how to make the EF work when you need more extensibility. Diego Mijelshon has created an answer with some of the pitfalls of EF and how NHibernate solves them.

推荐答案

由于J.吉洪做了解释EF功能非常出色,我只是列表,NHibernate的到处跑,EF圈方面:

Since J. Tihon did a great job on explaining EF features, I'll just list the areas where NHibernate runs circles around EF:

缓存 在EF无关开箱即用;有只是一个不支持采样 在新罕布什尔州拥有完整的缓存支持,包括基于数据库的失效。这也是可扩展的,基于提供程序的,这意味着它适用于不同类型的本地和分布式缓存 Caching EF has nothing out of the box; there's just an unsupported sample NH has complete caching support, including DB-based invalidation. It's also extensible and provider-based, meaning it works with different types of local and distributed caches 在EF现在没有 NH具有一次延迟加载集团实体或集合了广泛的支持(在任何DB),并持续改变以同样的方式(Oracle和SQL Server)。还有MultiQueries和将来的查询,让您任意组不同的查询在一个往返发送。 在英孚已经没有可扩展性可言。它甚至不支持枚举属性 没有类型映射很难codeD在新罕布什尔州。你可以扩展它支持任何值类型,您可以创建,修改现有的类型映射的方式,等等 在EF支持实体只有简单集合。许多一对多总是使用组合键 NH支持实体,值类型,组件类型,并且也索引集合,词典(其中两个的键和值可以是任何类型的)的集合。许多一对多的集合用自己的关键支持(idbag) 在EF没有记录开箱即用。有上述相同的不支持的采样 在新罕布什尔州拥有丰富的日志记录,使您可以方便地调试问题。它使用log4net的默认,但你可以使用任何你想要的日志框架 在英孚已经LINQ为主要查询语言。 LINQ具有高阻抗映射到关系型数据库的时候。 EF英孚的供应商不支持使用实体作为参数;你总是要使用的ID。还有多数民众赞成不良记录的查询语言 在NH已经LINQ(没有完全支持EF的,虽然),HQL,QueryOver和标准。 在英孚已经几乎没有什么 在新罕布什尔州有一个强大的事件系统,使您可以扩展或替换任何一点会话生命周期的它的行为:加载的对象,坚持变化,面色潮红等

我觉得可扩展性是其主要卖点。新罕布什尔州的每一个方面是正确地从其他地区脱钩,使用接口和基clases,你可以扩展当您需要,并在配置选项暴露出来。

I think extensibility is the main selling point. Every aspect of NH is correctly decoupled from the rest, using interfaces and base clases that you can extend whenever you need to, and exposed in configuration options.

EF如下使事情在默认情况下关闭的通常MS的模式,我们将看到什么是可扩展的更新版本。

EF follows the usual MS pattern of making things closed by default, and we'll see what's extensible later.