I originate from a java background.
But I'd like a mix-platform perspective on which is recognized as best practice for persisting objects.
The way in which I view it, you will find 3 camps:
- ORM camping
- direct query camping e.g. JDBC/DAO, iBatis
- LINQ camping
Do people still handcode queries (skipping ORM) ? Why, thinking about the choices available via JPA, Django, Rails.
There's nobody best practice for persistence (although the amount of people screaming that ORM is better practice might make you believe otherwise). The only real best practice is by using the technique that's most suitable for the team as well as your project.
We use ADO.Internet and saved methods for data access (though we all do possess some assistants making it extremely fast to create for example SP class wrapper machines, an IDataRecord to object translator, plus some greater order methods encapsulating common designs and error handling).
You will find a lot of causes of this that we will not get into here, but suffice to express that they're choices that actually work for the team which we concurs with. Which, in the finish during the day, is exactly what matters.
I'm presently reading through on persisting objects insinternet. As a result I am unable to provide a best practice, but maybe my experience may bring you some benefit. Up to a couple of several weeks ago I've always used handcoded queries, a poor habit from the ASP.classic days.
Linq2SQL - Very lightweight and simple to obtain up to date. I really like the strongly typed querying options cheap the SQL isn't performed at the same time. Rather it's performed whenever your totally ready (all of the filters applied) thus you are able to split the information access in the blocking from the data. Also Linq2SQL allows me use domain objects which are outside of the information objects that are dynamically produced. I haven't attempted Linq2SQL on the bigger project but to date it appears promising. Oh it only supports MS SQL the industry shame.
Entity Framework - I performed around by using it a bit and didn't enjoy it. It appears to wish to accomplish everything for me personally and it doesn't fully trust saved methods. EF supports Linq2Entities which again enables strongly typed queries. It is restricted to MS SQL however i might be wrong.
SubSonic 3. (Alpha) - This can be a more recent version of SubSonic which assists Linq. The awesome factor about SubSonic is it is dependant on template files (T4 templates, designed in C#) which you'll easily modify. Thus if you would like the car-produced code to appear different you simply change it out :). I've only attempted a preview to date and can consider the Alpha today. Have a look here SubSonic 3 Alpha. Supports MS SQL and can support Oracle, MySql etc. soon.
To date my conclusion is by using Linq2SQL until SubSonic is prepared after which change to that since SubSonics templates enables a lot more personalization.
There's a minimum of a different one: System Prevalence.
So far as I will tell, what's optimal for you personally is dependent a great deal in your conditions. I saw how for quite simple systems, using direct queries still might be a wise decision. Also, I've come across Hibernate fail well with complex, legacy database schemata, so utilizing an ORM may not continually be a legitimate option. System Prevalence should really unbeatingly fast, for those who have enough memory to suit all of your objects into RAM. Haven’t heard of LINQ, however i suppose it's its uses, too.
So, as so frequently, the reply is: know a number of tools to do the job, to ensure that you'll be able to make use of the one that is most suitable for the specific situation.