Question

During the beta of Stack Overflow, I have seen quite a few questions about LINQ SQL but know nothing about it... it sounds very interesting.

What is LINQ and how do I get started?

Links guides or documentation a bonus :)

PS: I am a long time C# developer who daily uses Datatables and Parameterized SQL

Was it helpful?

Solution

LINQ stands for Language Integrated Query and is a set of extensions for .NET that allow you to query data the same way from code and isn't tied to a specific data source. You can use the same LINQ code for SQL Server, XML, objects, DataSets, and Entities.

Here is a good intro from Scott Guthrie

This is a nice set of 101 LINQ Samples

OTHER TIPS

Two books you should consider for learning about LINQ, both from Manning:

The former was by far the better written, and taught me almost as much about LINQ in a single chapter than the latter did in a whole book. LINQ is built on a lot of foundation, and C# in Depth builds it up from the ground.

The second book is a whole lot better than nothing, and you will learn things specifically about LINQ that you won't learn in the first. But the first book will give you much better foundation, and puts up at least a token perspective instead of more or less blindly following the MS line. So, I'm recommending C# in Depth first and foremost for learning LINQ.

Mike

I recommend the Hooked On LINQ wiki. They've got some great introductory info, as well as more in depth info and samples on all of the operators.

I listed a lot of LINQ references in the show notes for Herding Code Episode 10 (on LINQ). One of my favorites is an MSDN Magazine article which explains how LINQ works from a framework perspective in a way which really helped me understand how it works.

Here are a couple of good tutorials (video) from OakLeaf Systems:

http://oakleafblog.blogspot.com/2007/04/two-new-linq-to-sql-video-segments-from.html http://oakleafblog.blogspot.com/2007/05/mike-taulty-posts-six-new-linq-to-xml.html

EDIT: I just ran into this great tool created by the author of C# in a Nutshell: http://www.linqpad.net/ It includes lots of great easy to follow samples.

I'd strongly suggest you have a play around with LINQPad (http://www.linqpad.net), it's a free tool which allows (umong others things) you to connect to a database server and query it using LINQ to SQL. It takes the pain out of having to set up Console Applications to do the playing.

Linq is short for "Language integrated query." It's a set of language enhancements built into C# and VB. Basically, what you get is a bunch of standard query operators that can be applied to any IEnumerable of type T. There's a lot of different linq providers for specific types of data- for example, there's linq to xml, linq to entities, even linq to sharepoint.

To get started with linq, in all its many forms, I suggest the book Pro Linq by Joseph C. Rattz. It's an excellent overview of Linq. He takes a ground-up approach, first describing all the language features (like Lambda Expressions and Expression Trees) that Linq is built on, and then moving on to some standard linq provider implementations.

Additionally, here's a pretty good MSDN article describing Linq: LINQ: .NET Language-Integrated Query

Now, Linq to Sql is a linq provider written specifically for SQL Server. Included in this provider is an OR/M, that gives you some handy-dandy functionality (like typing out all your sql tables, so you get a robust design-time view of your database schema.) It's totally awesome, and for me, has greatly speed up development time when working with a sql database. The book I recommended above also has a great section about using Linq To Sql. Also, here's a good "beginner's guide" article from MSDN: Linq To SQL: .NET Language-Integrated Query for Relational Data

To practice without the need to write wrap code just to execute linq-queries you could use linqpad.net

Here you go. I started with ScottGu's explanation/examples and went from there:

http://weblogs.asp.net/scottgu/archive/2007/05/19/using-linq-to-sql-part-1.aspx

I think this book:

C# in Depth

By Jon Skeet is an excellent programmers' guide that matches your exact needs (moving from earlier C# to C#3.5).

Also if you order it you get the electronic copy too - something more publishers should do (excellent for both Kindles and searching).

From MSDN, here are some papers, written by Anders and others:

PS after writing this, I see someone has already linked to these, but buried inside a paragraph, so I'll keep them pulled out here in list form as well.

There's a VB.Net version of the 101 Code Samples page too -

http://msdn.microsoft.com/en-us/vbasic/bb688088.aspx

There is a podcast here (shameless plug) that covers LINQ from one of the authors of LINQ in Action.

Deep Fried Bytes - Episode 14: LINQ’ing the Future of Development with Jim Wooley

Lots of great stuff in that show that may also help you out.

Here is a step by step tutorial on how to incorporate LINQ with your web applications within asp.net. Hope this helps http://www.progtalk.com/viewarticle.aspx?articleid=68

It may be useful to beginners on linq. The step by step guide with image. http://readerstimepass.blogspot.com/2010/11/step-by-step-guide-to-implement-linq-to.html

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top