views:

149

answers:

2

I would like to konw what is considered the most elegant C# .NET method to produce a Data Access Layer?

I am using MyGeneration DooDads. Is this an elegant solution?

Is it still acceptable to use the CRUD Stored Procedures + DAL Library for data access with .NET Entity Framework and NHibernate ORM tools?

+1  A: 

You can try to use domain model with ORM (Linq or Nhibernate). Visual Studio has a good support for Linq, it is easy to configure and use. All data access methods are encapsulated in the domain objects (data table objects) and all the query result is strong typed.

sza
+1  A: 

There is no answer to this question; everybody has different opinions.

Personally I like ORMs for simple home projects but wouldn't go near one in an application I actually have to support, and much prefer to use stored procedures to give the database a well defined interface that is abstracted from the storage mechanism.

Many people disagree with this point of view. Heck, even I'll probably disagree with it in a few years time. But it doesn't really matter what I think or what they think, if you're happy with what you're doing and find it efficient to code and easy to support, then it's elegant.

Greg Beech
good explanation but ORM and stored procedures can be used together :-)
Claudio Redi
@Claudio - They can, but what's the point in using a fully fledged ORM for working with stored procedures? All you really need is a simple data record <-> object mapping tool, not one that does all the relationship and querying stuff. I wrote one of those in about 200 lines which is much faster and simpler than an ORM.
Greg Beech