Solved

Considering Using LINQ in ASP.NET Web Application

Posted on 2011-03-13
9
492 Views
Last Modified: 2012-08-13
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: http://www.experts-exchange.com/Microsoft/Development/MS-SQL-Server/SQL_Server_2008/Q_26882433.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!

0
Comment
Question by:JMS1965
  • 4
  • 3
  • 2
9 Comments
 
LVL 19

Expert Comment

by:daveamour
ID: 35125723
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.
0
 
LVL 17

Expert Comment

by:ToAoM
ID: 35127099
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
0
 

Author Comment

by:JMS1965
ID: 35128899
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!
0
 
LVL 19

Accepted Solution

by:
daveamour earned 250 total points
ID: 35129035
L2E supports any database I believe and is generally a bigger better beast.

L2SQL supported just SQL Server and as ToAoM said, it is now pretty much obsolete.

Looks like your understanding is right and its fine that you have created your db.  You just drag objects onto the design surface and .net classes are created to model and interact with the db.   Its remarkably easy!
0
How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

 

Author Comment

by:JMS1965
ID: 35131574
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?
0
 
LVL 19

Expert Comment

by:daveamour
ID: 35131628
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.
0
 
LVL 17

Assisted Solution

by:ToAoM
ToAoM earned 250 total points
ID: 35137032
Linq-to-sql hasn't had any additional features added since it's original release, microsoft has stated that Linq-2-SQL should be considered great for Proof-of-concept, quick and dirty implementations, but not as a scalable, maintainable solution for applications that should be supported over a longer lifetime. They've built EF for that.

EF3 was a nice try, not well received by the community and is generally disliked for anything larger than a simple app. EF has since evolved and a lot of features have been added in EF4. It's now also on a much faster release schedule with many CTP's and RC's available.

In EF4 you can generate a model from your database and generate your classes from there. You can also create your classes and generate the model and the database from there. In my opinion the Model first approach would be best. Design the database in EF4, generate the database and the code from there. That gives you one, easily versioned location for your data model.
0
 

Author Comment

by:JMS1965
ID: 35138847
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.
0
 
LVL 19

Expert Comment

by:daveamour
ID: 35140032
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
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Problem to go to Web page 2 52
How to generate total number of records in db 35 27
SQl query 19 14
Log Backup 2 13
Hi all, It is important and often overlooked to understand “Database properties”. Often we see questions about "log files" or "where is the database" and one of the easiest ways to get general information about your database is to use “Database p…
This article explains how to reset the password of the sa account on a Microsoft SQL Server.  The steps in this article work in SQL 2005, 2008, 2008 R2, 2012, 2014 and 2016.
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

746 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now