Search code examples
.netentity-frameworkdata-access-layerstrongly-typed-dataset

Need recommendations for .Net data access layer for short time table project


I have a .Net winforms project with a short time table (about a week or so). I'm starting to code the data access layer. It's not a huge job, about 20 tables, stored either in a Sql Server or local MS Access databases. Data access is not my expertise so I'd like some recommendations.

My last experience was with .Net datasets and datatables, which gives an idea of how long it's been since I did this. I'm aware that datasets are pretty obsolete at this point, and they can definitely be a royal pain at times. I'm sure Entity Framework, nHibernate, Linq2SQL are all probably much better, and I want to use the best tool- but again, I have only a week. If there's too large a learning curve then it might not be feasible. Should I bite the bullet and stick with what I know (datasets), or is there a better tool that can be picked up and implemented fairly quickly?


Solution

  • I have just finished writing a Datalayer in 'Code-First' POCO classes using the Entity Framework (beta 5.1, although it will work with 4.2+).

    This means that you write your project entities in standard C# classes (asides from a few extra annotations such as what property should be a key) and you get very straightforward persistence. The Entity framework creates your SQL database, sets up all the tables and relationships so you can be up and running with a Data Access layer in next to no time. To store or retrieve objects you make a call to an (automatically created) object context, which feels like using LINQ to pull objects out of lists of your entities (in reality it is actually dynamically creating the SQL and querying the tables).

    There is a little bit of configuration involved, but like the above it is straightforward.

    See http://blogs.msdn.com/b/adonet/archive/2011/09/28/ef-4-2-code-first-walkthrough.aspx as a great tutorial