使用ORM的优缺点 [英] The advantages and disadvantages of using ORM

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

问题描述

我想讨论使用ORM(例如ADO.NET)的优缺点.

I would like to discuss the advantages and disadvantages of using ORM (such as ADO.NET).

  • 加快开发速度-无需重复的SQL代码.
  • 减少开发时间.
  • 降低开发成本.
  • 克服供应商特定的SQL差异-ORM知道如何编写供应商特定的SQL,因此您不必这样做.
  • 在他们学习使用ORM编程时,开发人员的生产力下降了.
  • 开发人员对代码的实际作用失去了了解-开发人员更容易使用SQL进行控制.
  • ORM有变慢的趋势.
  • ORM无法与SQL查询竞争复杂查询.

总而言之,我相信使用ORM的优点(主要是减少执行重复任务所花费的时间)的优势远远超过了ORM的缺点,例如很难掌握.

In summary, I believe that the advantages of using an ORM (mainly the reduced time taken to perform repetitive tasks) are far outweighed by the disadvantages of ORM e.g. it's difficulty to get to grips with.

人们可以指出我要去哪里哪里,并提出任何其他的优点/缺点.

Can people point out where I am going wrong and suggest any further advantages/disadvantages.

推荐答案

"ORM无法与SQL竞争 查询复杂查询."

"ORM fail to compete against SQL queries for complex queries."

  • 同时支持LINQ-SQL和Entity Framework,允许进行复杂的查询,甚至可以将SQL查询结果转换为对象.
  • 开发人员对 代码实际上在做什么- 开发人员可以更好地控制 SQL."

    "Developers loose understanding of what the code is actually doing - the developer is more in control using SQL."

    • 不是真的,如果您知道自己在做什么. SQL事件探查器足以查看翻译后的SQL查询是什么.
    • "ORM有变慢的趋势."

      "ORM has a tendency to be slow."

      • 是的,但是延迟加载和一些聪明的选择可以使加载速度几乎一样快.
      • 开发人员生产力下降,而 他们学习使用ORM编程."

        "Loss in developer productivity whilst they learn to program with ORM."

        • Hibernate和Entity Framework可能需要花费一些时间来学习,但从长远来看,它们将节省开发时间.另一方面,LINQ-SQL几乎没有学习曲线.
        • 我说,使用ORM,但请记住这一点.

          I say, use ORM but keep this in mind.

          1. 设计查询并编写代码 这将导致最少的数量 与服务器的往返次数.它是 往返所需的开销 这会占用时间.

          1. Design your queries and write code that will result in the least number of roundtrips with the server. It's the overhead taken for the roundtrip that takes up time.

          了解其他经历 人们已经选择了 在深入之前,ORM.

          Read about the experiences other people have had with the selected ORM before you dig in too deep.

          始终将您的查询与 在SQL中执行的实际 服务器分析器.

          Always compare your queries with the actual ones being executed in SQL server profiler.

          修改: 您不会像对待.Net或Java来编写操作系统那样,将ORM用于对性能至关重要的情况.选择之前请考虑您的要求.即使您不使用ORM,也将通过重复很多代码或使用数据字典来自己进行一些映射.为什么不使用ORM并知道如何使用其选项使其达到ALMOST的速度呢?权衡利弊,做出选择.

          You wouldn't use an ORM for a performance critical situation same way you wouldn't use .Net or Java to write an operating system. Consider your requirements before choosing. Even if you don't use an ORM, you will end up doing some mapping yourself either via repeating a lot of code or by using a data dictionary. Why not use an ORM and know how to use its options to make it ALMOST as fast? Weigh up the advantages and disadvantages and make your choice.

          http://mikehadlow.blogspot.ca/2012/06/when-should-i-use-orm.html

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

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