THE MANY FACES OF LINQ

LINQ (Language Integrated Query, pronounced “link”) is a data-selection mechanism designed to give programs the ability to select data in the same way from any data source. Ideally the program would be able to use exactly the same method to fetch data whether it’s stored in arrays, lists, relational databases, XML data, Excel worksheets, or some other data store. Currently the LINQ API supports data stored in relational databases, objects within the program stored in arrays or lists, and XML data.

LOTS OF LINQ
This chapter covers only the default LINQ providers included with Visual Basic, but you can build providers to make LINQ work with just about anything. For a list of some third-party LINQ providers to Google, Amazon, Excel, Active Directory, and more, see http://rshelton.com/archive/2008/07/11/list-of-linq-providers.aspx.
Microsoft also has created a LINQ provider for SharePoint. For more information, see http://msdn.microsoft.com/library/ee535491.aspx.

LINQ queries often let a program make complex data selections with very little code. For example, suppose you’re writing a billing program and you want to list customers with outstanding balances ordered by their balances. You could certainly use Visual Basic code to loop through a customer list to find the customers and then sort the results, but a LINQ query can find and order them in a few simple lines. The result isn’t always as fast as optimized Visual Basic code but it is often much simpler ...

Get Visual Basic 2012 Programmer's Reference now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.