.net ORM 比较 [英] .net ORM Comparison

查看:46
本文介绍了.net ORM 比较的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在和某人谈论实体框架,我还没有真正深入研究它,但我想学习它.但是,我仍然有点困惑我是否应该学习它.我听到很多人说你不应该使用实体框架,但我没有听到任何争论为什么会这样.

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.

所以我的问题是,使用实体框架的优点和缺点是什么与其他产品相比.喜欢

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...

我知道有一些重复问题.但它们都有些过时(2008、2009),老实说,这些论点也缺乏一些东西.我知道 Entity Framework 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. Tihon 在解释 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 没有任何开箱即用的东西;只有一个 不支持的示例
    • NH 具有完整的缓存支持,包括基于数据库的失效.它也是可扩展和基于提供程序的,这意味着它适用于不同类型的本地和分布式缓存
    • EF 没有
    • NH 广泛支持一次延迟加载实体或集合组(在任何数据库中),并以相同的方式(Oracle 和 SQL Server)持久化更改.还有 MultiQueries 和 Future Queries,可让您任意分组不同的查询以在一次往返中发送.
    • EF 根本没有可扩展性.它甚至不支持枚举属性
    • NH 中没有硬编码类型映射.您可以扩展它以支持您可以创建的任何值类型,修改现有类型的映射方式等
    • EF 仅支持简单的实体集合.多对多总是使用复合键
    • NH 支持实体集合、值类型、组件类型以及索引集合和字典(其中键和值都可以是任何类型).支持具有自己密钥的多对多集合 (idbag)
    • EF 没有开箱即用的注销功能.上面列出了相同的不受支持的示例
    • NH 具有广泛的日志记录,可让您轻松调试问题.它默认使用 log4net,但你可以使用任何你想要的日志框架
    • EF 将 LINQ 作为主要查询语言.LINQ 在映射到关系数据库时具有高阻抗.EF 的提供者不支持使用实体作为参数;你总是必须使用 ID.还有一种查询语言的文档很差
    • NH 有 LINQ(虽然不如 EF 完整)、HQL、QueryOver 和 Criteria.
    • EF 几乎一无所有
    • NH 拥有强大的事件系统,允许您在会话生命周期的任何点扩展或替换其行为:加载对象、持久更改、刷新等.

    我认为可扩展性是主要卖点.NH 的每个方面都与其他方面正确解耦,使用您可以随时扩展的接口和基类,并在配置选项中公开.

    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.

    这篇关于.net ORM 比较的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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