Using LINQ, we are able to create directly within the C# programming language entities called query expressions. These query expressions are based on numerous query operators that have been intentionally designed to look and feel very similar (but not quite identical) to a SQL expression. 

Core LINQ assemblies:

 System.Core.dll

Defines the types that represent the core LINQ API. This is the one assembly you must have access to. 

System.Data.Linq.dll 

Provides functionality for using LINQ with relational databases (LINQ to SQL). 

System.Xml.Linq.dll 

Defines a handful of types to integrate ADO.NET types into the LINQ programming paradigm (LINQ to DataSet). 

System.Data.DataSetExtensions.dll 

Provides functionality for using LINQ with XML document data (LINQ to XML). 


First, A Taste of LINQ

    static void QueryOverStrings()
    {
        // Assume we have an array of strings.
        string[] currentVideoGames = {"Morrowind", "BioShock",
        "Half Life 2: Episode 1", "The Darkness",
        "Daxter", "System Shock 2"};
        // Build a query expression to represent the items in the array that have more than 6 letters.
        IEnumerable<string> subset = from g in currentVideoGames
        where g.Length > 6 orderby g select g;
        // Print out the results.
        foreach (string s in subset)
        Console.WriteLine("Item: {0}", s);
    }

 Query Expressions

        from itemName in srcExpr
        join itemName in srcExpr on keyExpr equals keyExpr
        (into itemName)?
        let itemName = selExpr
        where predExpr
        orderby (keyExpr (ascending | descending)?)*
        select selExpr
        group selExpr by keyExpr
        into itemName query-body




Currently rated 4.0 by 2 people

  • Currently 4/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5