Which Data Access layer is the recommended today for ASP.net?
-
22-08-2019 - |
Question
I'm currently building a small website where I write down problems that arise and answers to them for others to see. Currently I'm using a DAL much like the one described here. Now I have been looking at other models, and in particular linq based models using Linq2SQL and the ADO.net Entries framework. I realize I'm moving the data access to the code layer in a way since I'm then filtering out for example a toplist with linq queries. The reason I started doing this was because the DAL was not really syncing up with the DB at all times and nullable types became not nullable when I changed something in the DB. Then if I would reimport the tables into the data table my queries would be lost.
My simple question is really, if you want a good DAL for ASP.net today, what would that be? Suggestions, experiences are more than welcome.
Solution
I personally preffer LINQ to SQL and ADO.NET Entity Framework. Microsoft guys also use those technologies in their latest projects (take a look at KOBE project for example). Thus, Microsoft recommends those two as well.
Though.. sometimes I use Data Access Application block from Enterprise Library and manual DAL coding when I need maximum control over it's functionality and implementation.
Other alternatives are: NHibernate, SubSonic, different ORM solutions like LLBLGen Pro.
Great books on this subject:
- Pro LINQ: Language Integrated Query in C# 2008 by Jr., Joseph C. Rattz
- LINQ in Action by Fabrice Marguerie
- Programming Entity Framework by Julia Lerman
- Murach's ADO.NET 3.5, LINQ, and the Entity Framework with VB 2008 by Anne Boehm
Related tools:
- LINQPad is also a great way to learn LINQ: it comes preloaded with 200 examples from the book, C# 3.0 in a Nutshell. There's no better way to experience the coolness of LINQ and functional programming.
OTHER TIPS
There are many options and each of them might prove better depending on your specific circumstance. Some options include:
- LINQ to SQL
- ADO.NET Entity Framework
- NHibernate
- SubSonic
- Writing one manually :)
My default choice is LINQ to SQL. It's a completely personal preference though. Many guys are NHibernate advocates.
I'm using OPF3 for my current project, mostly because it has excellent support for Pervasive.SQL v9.5. The support is fantastic, as well.