Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 500
  • Last Modified:

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: 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
JMS1965
Asked:
JMS1965
  • 4
  • 3
  • 2
2 Solutions
 
daveamourCommented:
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
 
Jesse HouwingScrum Trainer | Microsoft MVP | ALM Ranger | ConsultantCommented:
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
 
JMS1965Author Commented:
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
NFR key for Veeam Backup for Microsoft Office 365

Veeam is happy to provide a free NFR license (for 1 year, up to 10 users). This license allows for the non‑production use of Veeam Backup for Microsoft Office 365 in your home lab without any feature limitations.

 
daveamourCommented:
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
 
JMS1965Author Commented:
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
 
daveamourCommented:
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
 
Jesse HouwingScrum Trainer | Microsoft MVP | ALM Ranger | ConsultantCommented:
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
 
JMS1965Author Commented:
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
 
daveamourCommented:
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 Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

  • 4
  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now