views:

75

answers:

2

I could do with a bit of guidance understanding the world of asp.net & databases.

There seems to be so many options I'm not really sure what to look into & what to use in different situations.

I've created websites that have used datasets in the past, but I never really understood what was going on or why I should or shouldn't be using them over just creating a sql connection and running sql statements.

As I understand it there's the standard SQLReader, Datasets, Entity framework & LINQ.

How do these relate to each other? What's recommended & when?

Is there a guide to all of this somewhere? (I'm not really looking for how to do something as www.asp.net/learn shows you, but when & why to do something)

+2  A: 

There is tons of information available on the web for the pro's and con's of each method, but in a nutshell, going in the following order:

sqlreader
datasets
Linq
entity framework

You are going from fastest to slowest (in terms of raw performance) and least features and least complexity to most features and most complexity. That is a HUGE simplification, but I think its pretty valid. Raw performance is not always the most important concern, so its not as easy as picking the fastest method. Other factors come into play such as the size and complexity of the application you are working on, whether or not the programmers are also DBA's (or if you have a dedicated DBA who has their own requirements for db access), whether or not you will be required or allowed to use stored procedures etc.

I think as a developer it is important to understand all 4 methods(and others), and be able to pick the one most appropriate for the project you are working on.

I have worked with the first 3 (and plan on learning EF soon), and end up using sqlreader most of the time. Datareader has the least amount of overhead and runs the fastest in most cases, the trade-off being you need to write more of your own code.

EJB
To be fair, the performance losses are not always as substantial as this answer seems to imply... LINQ and EF can be quite fast when used right.
Rex M
Absolutely I agree. I have used Linq and very often the performance difference from datareader is inconsequential.
EJB
+1  A: 

Read this intro to ADO.NET; it's an implicit part of ASP.NET data access and should help you understand the data flows.

tsilb