This is kind of a strange post from me, but I've started thinking about some things in regards to ORM products due to my fun with LINQ To SQL. First of all, I'm not sure LINQ to SQL has this benefit (I could definitely be wrong about this), but I'm pretty sure that LINQ To SQL Entities does have (again, I don't speak as one who knows).
The difference is caching. I know that NHibernate has some strategies for caching your data, as does something like LLBLGen (I checked... I don't want Frans coming down on me). I'm pretty sure SubSonic has it (although I've let some of my skills in that area lapse a little).
I would argue that this is the one thing that ORMs do better than custom made DALs. Don't believe me! Ok, let's think about it...
Both ORMs and traditional DAL layers offer the ability to abstract the database away from us. I can simply make a call and get back an entity from the database. What if I'm in a web app where I'm doing multiple things... I need to load up the data to present it, and I need to look up the data to repopulate an object and then make changes based on the data that has come in... or maybe I need to load some related object... You get the idea.
Here's the part where ORMs excel IMO. An ORM that supports caching will make a single SQL call and will cache that data for the duration of the web call. That part is easy and a programmer carefully crafting their DAL will be able to manage the same effect (provided they are looking to optimize the code).
Some ORMs (and probably not all) have the ability to cache within the entire web application which means that a single update to an object will be reflected across the entire application. Again, this is possible for a conscientious developer to do... but it's starts to get a little more complex.
What happens if you have a team of developers working with you? Can you guarantee that the next time someone has to work in your file that the caching of entities will be appropriately handled... I doubt it (unless you wrote your own ORM).
Print | posted on Monday, February 04, 2008 2:59 PM