Linq Tutorial (Part 1): .NET Language-Integrated Query Overview

Description
Summary

Net framework feature that makes possible to query data over any information source in a uniformed way.

Description

What it is:

Linq makes available the Standard Query Operator API (referenced as Method Sintax) that defines the query operators as extension methods. It also provides a SQL-like syntax (referenced as Query Sintax) as a short hand method for invocation, that at compile time will be parsed and converted to the Standard Query Operators:

How can it  be used:

  • Linq to Objects component can be used for querying at memory level any IEnumerable<T>-based collections.
  • Linq to XML component (XLinq) can be used for querying at memory level the XML document that is converted to the XElement object.
  • Linq to SQL component (DLinq) implements a ORM component and can be used for querying SQL Server databases. Linq converts its queries to the SQL queries that are sent to the SQL server for the processing.
  • Linq to Datasets component can be used for querying at memory level dataset objects that must be first populated: The data can be retrieved through direct data access data or DLInq and then the data can be loaded as the result into a DataSet.
  • Linq to Entities component (DLinq) implements a ORM component and is based on the ADO.NET Entitiy Framework

Who can provide an implementation:

Oher commercial providers can implement the Standard Query Operators API. This way the application business layer(s) can use Linq queries to other type of  datasources than SQL Server without create any DDL physical dependency.
Examples of this scenario are:
  • LINQ to Active Directory
  • LINQ to Bindable Sources (SyncLINQ)
  • LINQ to CRM
  • LINQ To Geo – Language Integrated Query for Geospatial Data
  • LINQ to Excel
  • LINQ to Expressions (MetaLinq)
  • LINQ Extender (Toolkit for building LINQ Providers)
  • LINQ to Flickr
  • LINQ to Google
  • LINQ to Indexes (LINQ and i40)
  • LINQ to IQueryable (Matt Warren on Providers)
  • LINQ to JSON
  • LINQ to NHibernate
  • LINQ to JavaScript
  • LINQ to LDAP
  • LINQ to LLBLGen Pro
  • LINQ to Lucene
  • LINQ to Metaweb(freebase)
  • LINQ to MySQL, Oracle and PostgreSql (DbLinq)
  • LINQ to NCover
  • LINQ to Opf3
  • LINQ to Parallel (PLINQ)
  • LINQ to RDF Files
  • LINQ to Sharepoint
  • LINQ to SimpleDB
  • LINQ to Streams
  • LINQ to WebQueries
  • LINQ to WMI
  • LINQ to XtraGrid
  • LINQ to Amazon
Query Execution

In case of queries that wil return a sequence of values, Linq follows a deferred execution model, i.e. it is only executed when the query variable is iterated over in a For Each/foreach loop (The query will  be repeatedly executed, returning the updated information every time). To force immediate execution operators ToList, ToArray and ToDictionary can be used

In case of singleton queries that will produce only one value (e.g.  AverageCount and Max) execution is immediate

References
  1. Linq to Everything, for an updated list of providers
  2. Linq Query Sintax versus Method Sintax
  3. Language-Integrated Query (LINQ)