ORM vs. your own DAL with everything in Stored Procedures

I was arguing in an instant message window today. I was trying to relay the awesomeness that is Castle Project’s Active Record. I realized I’m not a very good arguer. I found myself digging for URLs which I know I had read, which do the comparison of DAL vs. ORM and dispel the myths that “you must use stored procedures for all database access”.

As I was skimming reverse chronologically through Ayende’s blog, I realized that for someone starting off, reading these things in some kind of logical order would help. I’ve decided to try to put things in some kind of order. Regarding Ayende/Oren’s blog, his really is all you need. He links to many other sites with excellent information.
So first, I’d like to try to build a case for using ORM.  I don’t have to do much, it has been done for me:

Just because you are using ORM, doesn’t mean it is magic.  http://www.ayende.com/Blog/YouCantEscapeTheComplexity.aspx  You have to still understand what is going on under the hood.  This is definitely an area in which I am lacking.

It is probably best to read Clemens Vasters post, then read Ayende’s follow ups.  They are very enlightining.  It is great to get both sides of the issue.

  1. http://friends.newtelligence.net/clemensv/PermaLink,guid,0fbf07a9-9e7a-4db4-a305-58250ac57a73.aspx
  2. http://www.ayende.com/Blog/2006/03/07/ClemensOnORMappers.aspx
  3. http://www.ayende.com/Blog/MoreAboutObjectRelationalMappersVsCustomDAL.aspx
  4. http://www.ayende.com/Blog/ClemensOnORMapeersTakeII.aspx

Don’t think DLINQ is the answer, or that it does more.  Many DLINQ fans don’t realize that most ORMs have been able to do this stuff for years.  http://www.ayende.com/Blog/UsingORMProperly.aspx

A comparison of LLBLGen to NHibernate.  Now to be fair, Oren is a contributer to NHibernate so he may be a little biased.  I’ve not used LLBLGen, but I have browsed its documentation, and I’d also rather use NHibernate.  http://www.ayende.com/Blog/LearningAboutLLBLGen.aspx

On security of the stored procedure approach vs. ORM.  This is a great detailed description.  http://www.ayende.com/Blog/OneUponATimeInAnITOperationFarFarAway.aspx

For some reason there are LIES surrounding ORMs.  Know this:  They are lies.  http://www.ayende.com/Blog/PissedOffByVanatecOpenAccess.aspx
Some people have responded to others and said “I’ll write my own!”  Oren(Ayende) gives 25 reasons not to:

http://www.ayende.com/Blog/25ReasonsNotToWriteYourOwnObjectRelationalMapper.aspx

It turns out he was repeating himself, because he mentioned it a little less detailed months before: http://www.ayende.com/Blog/YouReallyShouldntWriteYourOwnORM.aspx

A common problem to run into once you start using an ORM, any ORM, is know as the SELECT N+1 Problem.  http://www.ayende.com/Blog/CombatingTheSelectN1ProblemInNHibernate.aspx

I’ve never done this, but I should probably keep it in mind.  I’ll bet I could use it, and it is a great example of how quickly you can get things done using these tools.  http://www.ayende.com/Blog/UnderusedNHibernateFeatureCreatingObjectsInTheSelectClause.aspx

I haven’t even read these yet. How could I have missed them?  They go into how it works.
All you wanted to know about Castle’s ActiveRecord – Part I
All you wanted to know about Castle’s ActiveRecord – Part 2

Finally, there is a whole series of posts building up a demo app, including using Brail for MVC.  This is ActiveRecord + MonoRail stuff, a great way to see the big picture.  http://www.ayende.com/Blog/CasleDemoAppMidwaySummary.aspx
A couple of items which I think are worth reading, but I couldn’t fit into this semi-ordered list of links.

  1. http://www.ayende.com/Blog/AFewWordsAboutTheDecoratorPattern.aspx
  2. http://www.ayende.com/Blog/AdvancedUsesForORM.aspx
  3. http://www.ayende.com/Blog/ComplexSearching.aspx
  4. http://www.codeproject.com/aspnet/NHibernateBestPractices.asp
  5. http://www.codeproject.com/cs/design/IntroducingCastle.asp
  6. http://www.codeproject.com/cs/design/introducingcastleii.asp

Once you are familiar with the ActiveRecord library, I highly recommend checking out the rest of CastleProject.  Windsor is awesome.  MonoRail is ASP.NET on steroids.

4 thoughts on “ORM vs. your own DAL with everything in Stored Procedures”

  1. Pingback: Ayende @ Blog

Comments are closed.