For Linq Practice

If you want some practice on LINQ with exercises and answers, really easy to set up and, in my opinion, awesome:

Download from git, open in Visual Studio. Your job is to make the tests pass.

[disclosure: i learned some linq from it and I contribute to the project so yeah i think it's an awesome, fast and efficient way to learn.]


My 2 cents , Read chapters "11 Query expressions and LINQ to Objects" and "12 LINQ beyond collections" in "C# in Depth" book to understand how LINQ works.


Some caveats about using LINQ to SQL:

Has Microsoft really killed LINQ to SQL?


There's also some controversy about the first version of Entity Framework, including a petition.


I think, the answer to "What flavors of LINQ are there?" is incomplete. First of all, you can create your own "flavor". Yes, it is an advanced task, but there are a lot of different LINQ implementations now.

Here is the list of existing LINQ providers (plus some more resources on learning LINQ) on Charlie Calvert's blog: Links to LINQ.

And also there is an excellent series of blog posts by Matt Warren on how to create your own LINQ Provider: LINQ: Building an IQueryable provider series


Get the book Linq in Action it is an easy read for a coding book and really teaches you how to use Linq and the new features of .NET 3.5 some of the cool parts they put in for the language.


IMHO, an overlooked, but important, benefit is the coding efficiency of LINQ, e.g how much can be accomplished with so little code. I personally find the query syntax easy to read and comprehend.


A few LINQ Tips:

  • Apply filters before a join to improve query performance
  • Filter LINQ queries using object reference comparison
  • Apply aggregates to empty collections in LINQ to SQL queries
  • Delay loading a property in LINQ to SQL
  • Use table-valued functions with eager loading turned on
  • Put joins in the correct order in a LINQ to Objects query
  • Compose a LINQ query inside a loop


Mention LINQ to Entities since ADO.NET Entity Framework will be an important .NET module.

Related Query

More Query from same tag