Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Considering Using LINQ in ASP.NET Web Application

Posted on 2011-03-13
9
Medium Priority
?
498 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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:Jesse Houwing
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
Three Reasons Why Backup is Strategic

Backup is strategic to your business because your data is strategic to your business. Without backup, your business will fail. This white paper explains why it is vital for you to design and immediately execute a backup strategy to protect 100 percent of your data.

 
LVL 19

Accepted Solution

by:
daveamour earned 1000 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
 

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:Jesse Houwing
Jesse Houwing earned 1000 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

Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

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…
How to leverage one TLS certificate to encrypt Microsoft SQL traffic and Remote Desktop Services, versus creating multiple tickets for the same server.
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …

660 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