The LINQ Project: Visual C#
Microsoft .NET Language-Integrated Query

 

 

 

 

 

 

 

 

Microsoft .NET LINQ Preview (May 2006) is now installed on your machine.

Welcome to the Microsoft .NET LINQ Preview (May 2006).  This is an enhanced version of the LINQ Preview unveiled at PDC 2005. It contains documentation and samples to let you see Language-Integrated Query in action, as well as preliminary IDE support so you can write your own queries.

This release includes a prototype C# 3.0 compiler, as well as preliminary IDE support for Visual Studio 2005 and Visual C# 2005 Express.

The following are the requirements for this preview:

  • The prototype C# compiler and the samples below require one of the following:
      • Visual Studio 2005 (required for DLinq designer)
      • Visual C# 2005 Express
  • Windows XP Service Pack 2, Windows 2000 Service Pack 4 or Windows Server 2003 or Windows Vista beta2 with WinFX Runtime beta2 are required.  The LINQ Preview has not been tested on 64-bit operating systems.
  • English-language versions of both Windows and Visual Studio/Visual C#/Visual Basic are recommended. The LINQ Preview has not been tested on other platforms.

Some samples and templates have extra requirements:

  • To run DLinq samples, you must have one of the following installed on this machine:
    • SQL Server 2005 Express (included with Visual Studio 2005 or downloadable from http://lab.msdn.microsoft.com/express/sql/default.aspx)
    • The following versions of SQL Server will work, but require some minor code changes to the samples first (see the Troubleshooting section below for instructions):
      • SQL Server 2005 (non-Express)
      • SQL Server 2000a
  • To use the LINQ WinFX project template, you must have:
    • WinFX Beta 2 SDK installed

LINQ is on the web!  Check out the LINQ Home Page on MSDN for more information including videos with the designers of LINQ, latest blog posts and forum where you can share and discuss your experiences with the LINQ Project.

What’s new?

LINQ:

  • IQueryable<T> enables pluggable query processors.
    • ToQueryable provides a way to get an expression tree from an IEnumerable<T> so that a pluggable query processor can optimize and execute it
    • Expression.Compile enables compilation of an expression tree for in-memory execution
  • Join support has been added: Join operator provides inner equi-join and a powerful GroupJoin operator retains the hierarchical structure while providing additional outer-join like capabilities
  • A family of additional operators: Single, SingleOrDefault, Last, LastOrDefault, ElementAt, ElementAtOrDefault

C# Language:

  • Query expressions now provide:
    • Join syntax for using Join and GroupJoin
    • Let clause for declaring temporary variables in query expression
  • Lambda statement blocks are enabled in addition to lambda expressions

C# IDE:

  • Support for copy-pasting XML for simplified use of XLinq

DLinq:

  • A graphical designer has been added for generating mapped classes. This designer requires Visual Studio 2005 Professional Edition or above.
  • Inheritance
  • Multi-tier entity support
  • Enhanced support for stored procedures and user-defined functions
  • Improved concurrency conflict resolution
  • Remote / local EntitySet
  • XML mapping file
  • Additional .NET functions

XLinq

  • Supports annotations, an extensibility point for user data
  • Improved support for XML mixed content
  • Support for streaming output

LINQ over DataSet:

  • Adds new LINQ component to query DataTables – implements the LINQ query pattern including join
  • Adds DataSet-specific operators like DistinctRows, UnionRows for traditional relational set operations
  • Provides ToDataTable() operator to get a DataTable from a sequence

Miscellaneous:

  • Web project template that allows prototype C# compiler to be used in web projects
  • WinForms and ASP.NET databinding samples
  • An expression tree visualizer for better inspection of expression trees
  • A DLinq query visualizer for better debugging experience

Documents:

  • LINQ Project Overview – An explanation of the motivations behind Language-Integrated Query, and a peek into some of the new language capabilities that allow for rich type-checked querying of in-memory data, relational data stores, and XML.
  • Standard Query Operators – A description of the Standard Query Operators, the building blocks that are composed to form queries.
    • Sequence.cs – The implementation of the Standard Query Operators which demonstrates how they work and models how you can write your own operators.
  • C# 3.0 Specification – The detailed specifications of the new C# language features that come together to form the foundation for LINQ.
  • DLinq Overview for C# Developers – An examination of the architecture of DLinq, which provides type-safe, compiler-checked querying against relational data stores, such as SQL Server.
  • Walkthrough: Using the DLinq Designer – Shows how use the designer to create DLinq objects and use them for databinding in a Windows Form.
  • XLinq Overview – A look at how to use XLinq, a new lightweight XML object model that allows for both language-integrated querying and transformation of XML data.
    • XLinq Reference – An in-depth description of each of the classes within the XLinq object model.
  • LINQ over DataSet – A guide to using standard query operators and additional operators over DataSet
  • Hands on Labs – Self-paced walkthroughs for each of the major components of LINQ: Standard Query Operators, DLinq and XLinq, as well as the C# language features that make Language- Integrated Query possible.

C# Support:

The installer sets up several LINQ project templates (LINQ Windows Application, LINQ Web Site, LINQ Console Application, LINQ WinFX Application and LINQ Library) that you can use to create your own C# 3.0 projects using LINQ.

IDE Support (for Visual Studio 2005/C# 2005 Express):

Project LINQ relies on several changes to the C# language.  C# 3.0 contains new keywords and syntax that are not considered valid by the Visual Studio 2005 IDE.  The result is that editing LINQ-enabled C# code can be difficult: For example, there is no IntelliSense™ support for the new language features, errors are incorrectly reported in the output window, and the code editor underlines valid C# 3.0 code with red squiggles.  A modified C# language service has been created to help alleviate these problems in the IDE, to provide the new keywords in the completion list, and to provide extension methods in IntelliSense™.

While this preliminary IDE support greatly enhances the editing experience when writing C# 3.0 code in VS 2005, the language service and compiler are still very much in an alpha phase.  In the event of a compiler error, many more errors may be reported than are actually present.  If you see a large number of errors when building C# 3.0 code, fix the top error in the error list first and build after each fix.

Follow these steps to enable LINQ IDE support for Visual Studio 2005 and Visual C# 2005 Express: 

  1. First, verify that you are running the release version of Visual Studio 2005 or Visual C# 2005 Express.  The language service that will be installed only works with the English version of VS 2005/C# 2005 Express and may cause severe problems if installed on earlier versions.  You can verify your version by selecting Help\About in Visual Studio 2005. 
  2. Shut down any running instances of Visual Studio.
  3. Open the \bin folder under the LINQ preview installation directory and run “Install C# IDE Support”.
  4. Start VS 2005/C# 2005 Express.

Follow these steps to restore your original VS 2005/C# 2005 Express language service:

  1. Shut down any running instances of Visual Studio.
  2. Open the \bin folder under the LINQ preview installation directory and run “Uninstall C# IDE Support”.
  3. Start VS 2005/C# 2005 Express.

Visual Basic Support:

If you also have Visual Basic installed on your machine, the files for preview for Visual Basic are installed. The readme for Visual Basic can be found here. The preview files for Visual Basic are not installed if you do not have Visual Basic installed as a part of Microsoft Visual Studio 2005 or Microsoft Visual Basic Express 2005.

Samples:

Loading samples requires Visual Studio 2005 or Visual C# 2005.  It is recommended that you install the IDE support above first to improve your experience navigating through and writing C# 3.0 code.

  • SampleQueries – The SampleQueries project contains hundreds of sample Standard Query Operator, DLinq and XLinq queries that you can try out and modify to get a feel for the capabilities of Language-Integrated Query.
  • ASP.NET Databinding – Show a DLinqDataSource that helps you quickly write simple web applications.
  • Expression tree visualizer – Shows how to view an expression tree generated by a compiler.
  • Interactive Query – Dynamically extend DLinq queries by adding filter, sort, paging expressions.
  • LogicProgramming – The LogicProgramming sample shows how to implement a domain specific language inside of C# using compiler generated expression trees.
  • Reflector – The Reflector sample illustrates queries over components from System.Reflection and System.Xml.XLinq.  The result is an HTML document outlining the public APIs for a given assembly, in this case System.Xml.XLinq.dll.
  • Rss – The Rss sample uses System.Xml.XLinq to build a tiny web server that aggregates several RSS feeds.
  • WCFLinq – The WCFLinq sample highlights both the Windows Communication Framework (“Indigo”) and LINQ. The sample shows using XLinq for the creation and processing of XML messages and the use of Linq against [DataContract] types.
  • WinFormsDataBinding – The WinFormsDataBinding sample illustrates how the results of DLinq queries can be bound to WinForms grid for display and updates.
  • XLinqIntro – The XLinqIntro sample is a short introduction to System.Xml.XLinq, building on familiarity with the XML DOM API.

Forum:

Join fellow LINQ Preview users for discussions at the LINQ forum

Bloggers:

A number of Microsoft bloggers regularly talk about the LINQ Project, so check out their blogs regularly for the latest tips and tricks! The latest blog entries can be found on the LINQ Home Page. Additional information about C# can be found at the Visual C# Developer Center on MSDN.

Known Issues and Troubleshooting:

A list of known issues and workarounds where available is on the LINQ home page.

 


Copyright © 2006 Microsoft Corporation.  All rights reserved.