Link to home
Start Free TrialLog in
Avatar of JMS1965
JMS1965Flag for United States of America

asked on

Considering Using LINQ in ASP.NET Web Application

Hello -

I am building my first web application using ASP.NET 4 with a SQL Server 2008 database.  (My background is in Access / VB apps.)

This app will require lots of interation with the database (reads, writes, updates, deletes). I have learned how to work with the database using connections and data readers (my approach is detailed here: https://www.experts-exchange.com/questions/26882433/Retrieving-SQL-Server-Data-in-ASP-NET-Code.html).

This is working fine, but I am starting to learn a bit about LINQ and am wondering if this is a better way to go. I'm interesting in hearing about pros and cons of LINQ vs. ADO.

In addition to general pros and cons, a specific question I have is are there limitations to using LINQ, for example does it have specific requirements for the host server (I'm developing this on a stand-alone laptop but will deploy to a commercial host), or specific requirements for the user's browser (certain versions, can it be used on mobile browsers, etc.)?

Thanks in advance for your input!

Avatar of daveamour
daveamour
Flag of United Kingdom of Great Britain and Northern Ireland image

Linq to Entities or Linq ro SQL is what I assume you are talking about rather than just Linq itself.

I would highly recoemnd it - it will save many hours of time and make maintenenace easier.

These frameworks generate classes to model and interact with the db - I can't think of any hosting issues as long as they have the right framework version.  I would go with Linq to Entities though.
Avatar of Jesse Houwing
LINQ-to-SQL is 'deprecated' for serious development.

Entity Framework 4 Code first is the way to go.
http://weblogs.asp.net/scottgu/archive/2010/07/16/code-first-development-with-entity-framework-4.aspx
Avatar of JMS1965

ASKER

daveamour and ToAoM:

Thanks very much for the input and encouragement. I read a lot on Linq to SQL yesterday and played with it a bit, and am excited about using Linq.

As my database is SQL Server 2008, I assumed I would use Linq to SQL, but both of you recommend Linq to Entities over this.

What are the drawbacks / risks to using Linq-to-SQL, and how does Linq to Entities differ?

One resource I am using is Alessandro Del Sole's Visual Basic 2010 Unleashed. Yesterday I was working through the chapter on "LINQ to SQL", but now I notice that the the next chapter is "Introducing ADO.NET Entity Framework", which I assume is what you mean by Linq to Entities. Flipping through just the first few pages, it looks like this approach uses "Entity Data Models" (.edmx) as opposed to the "Data Contexts" (.dbml) provided by the LINQ to SQL Classes.  Am I on the right track here?

One other item ... not sure if this matters or not, but I have already created the SQL Server database structure that this app will use.

Thanks again!
ASKER CERTIFIED SOLUTION
Avatar of daveamour
daveamour
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of JMS1965

ASKER

Sounds great!  One last question:

I can see where Linq-to-Entities will allow for faster development and debugging.  Is there any noticeable performance hit for the end-user once the app is deployed ... speed issues in L2E vs. the non-Linq / DataReader approach?
Generally I would say no or at least nothing noticeable.

If you were to be very scientific about it then straight ado.net code should perform better as long as your SQL is spot on but really its not noticeable at all.

The more you abstract code, the slower it will get but that amount of slowness is microscopic I think.
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of JMS1965

ASKER

Thanks to Daveamour and ToAoM for all the helpful information! I plan to move forward with this project using Linq-to-Entities.

For anyone reading this thread in the future, I just want to add that there are some very good Linq tutorials on YouTube.
Thanks for the points.

If you can spare the dosh I would also recomend

http://www.learnvisualstudio.net/Members/Default.aspx

Some great video content on there