Solved

Considering Using LINQ in ASP.NET Web Application

Posted on 2011-03-13
9
496 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
Comparison of Amazon Drive, Google Drive, OneDrive

What is Best for Backup: Amazon Drive, Google Drive or MS OneDrive? In this free whitepaper we look at their performance, pricing, and platform availability to help you decide which cloud drive is right for your situation. Download and read the results of our testing for free!

 
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
 

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 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

Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

Question has a verified solution.

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

Suggested Solutions

Naughty Me. While I was changing the database name from DB1 to DB_PROD1 (yep it's not real database name ^v^), I changed the database name and notified my application fellows that I did it. They turn on the application, and everything is working. A …
In this article I will describe the Backup & Restore method as one possible migration process and I will add the extra tasks needed for an upgrade when and where is applied so it will cover all.
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…

752 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