Why and When to use LINQ?

This is a fair question but has been asked many times already. See these earlier questions for a more in depth and broader coverage:

All about Linq

Beginners guide to Linq

What's the hardest or most misunderstood aspect of Linq


Just to clarify there are differences between the concept of LINQ and LINQ to SQL.

LINQ is a query syntax, not a language or an O/RM. You can build an O/RM on top of the syntax provided by LINQ.

Since I gather that your question is really When to use LINQ to SQL I'll just address that.

LINQ to SQL is best used when you are:

  • Only ever targeting MS SQL 2000+
  • Doing RAD

I've used LINQ to SQL on a couple of commercial products and quite a few of my own products and found these benefits:

  • Familiar language to code in (C#/ VB.NET)
  • Easier to maintain (we have more .NET than SQL gurus on staff)
  • SQL generated is well structured and very optimal
  • Allows direct translation of business rules to SQL while still keeping all business logic in a single project

As for LINQ as a concept I use it all the time, because I understand what it can/can't do and how to use it properly. Like any language feature it can be miss-used easily if people don't have an understanding of what it is and how to use it. I recommend the following blogs to get some of the concepts of LINQ down:

  • Bart De Smet - advanced
  • Charlie Calvert
  • Wriju