User talk:Soumyasch/Incubator/LINQ

Architecture

 * Three parts: Standard Query Operators, Language Extensions, LINQ Providers.
 * Language Extensions are optional; keywords map to methods.

Standard Query Operators

 * About the standard query operators API.
 * Works on IEnumerable collections. Collections can implement IQueryable, which is the access point for LINQ providers for that collection type. Queries will be handed over to the provider via this interface.
 * Implemented as generic methods.
 * Query composability by calling a query operator on the result of a previous query operation.
 * Query results are enumerable.
 * That they can work without language extensions.
 * Projection and join create new classes, projection with less number of properties as the class of objects on which the projection runs, joins merge the properties of all the classes of objects across which the query runs. The classes must be declared before compilation. This is necessary for type-checking.
 * Select returns objects of same class as the data source.
 * Join predicates are passed to the methods as delegates, which are executed on each instance in the collection.
 * Objects must be fully typed. So, any external data source must be surfaced as typed objects. For SQL databases, this means the database must be O/R mapped to .NET classes.
 * Queries not just for filtering data out from data sources. Certain algorithms can also be implemented as queries. Especially those which run a certain routine over a lot of data - programs that are suited for SPMD programs. The data can be represented as an enumerable collection. The query will provide via a delegate the function that needs to be executed on them. For example, the Ray-tracer using LINQ.
 * Lazy evaluation. The series of method calls, along with the delegates and variables as parameters to the delegates can be represented as expression trees. Expression trees implemented as library, so language support not necessary. Expression trees allow the query structure to be examined at runtime.
 * These components are implemented as library and shared by all .NET languages

Language Extensions

 * Makes queries first class language construct.
 * Anonymous types with automatic type inference using Reflection. With this feature, the new classes generated by projection and joins need not be defined explicitly, but the language will infer the fields they will have and generate the classes appropriately.
 * The role of the compiler.
 * Extension methods extend the method-set of the generated classes, so that the results of the queries have the query methods, which can be called like a regular method. For query composability.
 * Lambdas generate expression trees.
 * Lambdas are syntactic sugar for creating the delegate inside the query expression.
 * Needs to be implemented on a per-language basis.

Code sample

 * Code sample in C# 3.0
 * Code sample in VB 9.0

LINQ Providers

 * Receive expression trees representing the queries.
 * Analyze the tree and either create a query specific for the data source, or create an execution strategy specific to the data source.
 * Needs to implement all the standard query operators, so that regardless of the provider, an uniform querying model can be used.
 * To be implemented on a per-data source basis, an implementation can be consumed by any .NET language.
 * How providers plug in to the LINQ runtime using IQueryable and IQueryProvider.
 * How LINQ providers can be created.

LINQ to SQL

 * Needs an O/R mapping solution.
 * Generates SQL queries from expression trees; executed at database server.
 * Works with stored procedures and user defined functions.
 * Generated SQL viewable in Visual Studio 2008 debugger.

Other providers

 * LINQ to Windows Search
 * LINQ to Flickr
 * LINQ to Amazon

PLINQ

 * Part of the Parallel FX Library, along with Task Parallel Library.
 * Parallel query execution engine.
 * Not just searching data, algorithms expressed as queries will also benefit from running using PLINQ on multi-core systems.
 * Compatible with LINQ to a very large extent. Most queries will run without modification.
 * To be released with a future iteration of .NET Framework.

O/R Designer

 * Comes with Visual Studio 2008.

SQLMetal

 * Generates typed classes corresponding to SQL Server databases automatically from the database.