(redirected from Programming.LINQ)

 

 

General Notes

Language Integrated Query (LINQ) is a Microsoft project that adds a native querying syntax reminiscent of SQL to .NET Framework programming languages, initially to the Visual Basic .NET and C# languages. Many of the concepts that LINQ has introduced were originally trialled in Microsoft’s Cω research project.

 

LINQ defines standard query operators that allow code written in LINQ-enabled languages to filter, enumerate, and create projections of several types of collections using the same syntax. Such collections may include arrays, enumerable classes, XML, datasets from relational databases, and third party data sources. The LINQ project uses features of version 2.0 of the .NET Framework, new LINQ-related assemblies, and extensions to the C# and Visual Basic .NET languages. Microsoft has distributed a preview release of LINQ, consisting of those libraries and compilers for C# 3.0 and Visual Basic 9. Other languages, such as F# and Nemerle, have also announced preliminary support. Wikipedia

 

There are two syntaxes - Lambda and Comprehension/Query, which is more like SQL (hence it’s often called query syntax).

 

http://msdn2.microsoft.com/en-us/netframework/aa904594.aspx

 

 

http://blogs.techrepublic.com.com/programming-and-development/?p=594 - Access XML data using LINQ to XML

 

 

 

Tools

LINQPad -- recommended by Nick Gotch

 

LINQ on the other hand is both awesome and it doesn't take that long to grok.  There's a free app called LINQPad.  Download that, go to the samples page and play around.  You can use LINQPad in place of SQL Server Manager. A week or two and you'll master the basics.

The big benefit to Linq is strong data typing: With ADO.NET you type all your SQL commands in strings so you have no intellisense feedback, no compile-time checking, etc..  With Linq you type your select, update, insert, etc.. all in actual .NET code so you get real, live feedback.  Technically the speed benchmarks a little slower than ADO.NET (not much but still something to be aware of) but the advantages more than compensate IMHO.

 

 

VB vs C# syntax

http://stackoverflow.com/questions/6515037/differences-in-linq-syntax-between-vb-net-and-c-sharp
http://blogs.msdn.com/b/goto100/archive/2008/08/05/visual-basic-vs-c-linq-syntax.aspx

 

 

Link Dump

Programming a Recursive Descent Parser using LINQ - 7 part series

 

 

See Also

 

 

Category tags

Programming SQL