Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

.NET and database layers

When I last worked in programming, we were trying to move away from DataReaders and the traditional ADO.NET API toward Object Relational Mapping (ORM).

To do this, we generated a DataContext of our DB via sqlmetal. There was then a thin data layer that made the DataContext private, and any code needing to access the database would have to use a public method in this thin data layer. These methods were basically stored procedures; they would perform queries on the database via LINQ to SQL.

Is this a common approach today? I mean, is everyone whose using the .NET 3.5 framework really running sqlmetal in their build process, or what? It almost seemed like a hack at the time.

Basically, I'd like to know if LINQ to SQL and sqlmetal is what to expect if I'm go to write a DAL today at a .NET 3.5 shop that doesn't employ a third-party, open-source ORM.

like image 272
core Avatar asked Mar 06 '09 19:03

core


2 Answers

It is still considered best practice to have some sort of data access layer. Whether this is best achieved with a ORM is a heavily debated issue. There is one faction that generally argues that ORM's are the way to go. Another faction argues that stored procedures and database centric is the best route.

Also, this may not be exactly the poster you meant, but it similar (and also the one in my cubicle)

http://download.microsoft.com/download/4/a/3/4a3c7c55-84ab-4588-84a4-f96424a7d82d/NET35_Namespaces_Poster_LORES.pdf

like image 78
Jacob Adams Avatar answered Sep 30 '22 13:09

Jacob Adams


Your approach is good. I currently use Astroria services (ADO.NET Data Services). There was a nice introduction in MSDN Magazine about this.

I also like the new PLINQO (requires CodeSmith Tools though). This is very slick in my opinion.

When I have such a DAL (service layer), I just consume this service from my client application (Silverlight or ASP.NET MVC).

like image 39
David Pokluda Avatar answered Sep 30 '22 13:09

David Pokluda