views:

5072

answers:

15

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

+1  A: 

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

DannySmurf
+24  A: 

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

SitWalkStand
101 LINQ Sampels is fantastic, I still use it a lot and always refer it for others
Slace
+6  A: 
KP
+6  A: 

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.

urini
+9  A: 

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

Mike
+4  A: 

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

Evan
+1  A: 

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

Keith
+1  A: 

A bit old but still relevant: http://www.developerzen.com/2007/09/17/introduction-to-linq/

Eran Kampf
+6  A: 

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.

Jon Galloway
+1  A: 

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.

pbh101
+3  A: 

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

Davide Vosti
+1  A: 

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

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

TheoJones
+4  A: 

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.

I cover some of the other stuff on my blog (using LINQPad for non-LINQ code testing) and link off to a really good video on LINQPad: http://www.aaron-powell.com/blog.aspx?id=1246

Slace
A: 

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.

Keith Elder
A: 

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

Janani Krish