The advantages and disadvantages of using ORM [closed]

“ORM fail to compete against SQL
queries for complex queries.”

  • Well both LINQ-SQL and Entity Framework Allow complex queries and even translation of SQL query results into objects.

“Developers loose understanding of
what the code is actually doing – the
developer is more in control using
SQL.”

  • Not really, if you know what you are doing. SQL profiler is enough to see what the translated SQL queries are.

“ORM has a tendency to be slow.”

  • Yes, but delay loading and some smart options can make it almost as fast.

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

  • Hibernate and the Entity Framework might take time to learn but in the long run they will save time in development. LINQ-SQL on the other hand has little to no learning curve involved.

I say, use ORM but keep this in mind.

  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.

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

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

Edit:
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

Leave a Comment