You are previewing LINQ Quickly.
O'Reilly logo
LINQ Quickly

Book Description

A Practical Guide to Programming Language Integrated Query with C#

  • LINQ to Objects

  • LINQ to XML

  • LINQ to SQL

  • LINQ to DataSets

  • LINQ to XSD

  • In Detail

    This book gets you started with LINQ and shows how it will make your programming life easier by making use of new features from the .NET Framework 3.0. This book is split into seven chapters, each of which is dedicated to presenting a feature of LINQ and its usage in real-life scenarios.

    Language Integrated Query (LINQ) is a new feature in Visual Studio 2008 that extends its query capabilities, using C# and Visual Basic. Visual Studio 2008 comes with LINQ provider assemblies that enable the use of LINQ with data sources such as in-memory collections, SQL relational databases, ADO.NET Datasets, XML documents, etc.

    In Visual Studio 2008, Visual C# and Visual Basic are the languages that implement the LINQ language extensions. LINQ language extensions use the new standard query operators API, which is the query language for any collection that implements IEnumerable.

    Table of Contents

    1. LINQ Quickly
    2. Credits
    3. About the Author
    4. About the Reviewer
    5. Preface
      1. What This Book Covers
      2. Conventions
      3. Reader Feedback
      4. Customer Support
        1. Downloading the Example Code for the Book
        2. Errata
        3. Questions
    6. 1. Overview
      1. LINQ Architecture
      2. Integration with SQL
      3. Integration with XML
      4. Support for C# 3.0 Language Features
        1. Anonymous Types
        2. Object Initializers
          1. Collection Initializers
          2. Partial Methods
        3. Implicitly Typed Local Variables
        4. Extensions
        5. Expressions
          1. Lambda Expressions
          2. Query Expressions
          3. Expression Trees
      5. Summary
    7. 2. LINQ to Objects
      1. Array of Integers
      2. Collection of Objects
      3. Reading from Strings
      4. Reading from Text Files
      5. Summary
    8. 3. LINQ to XML
      1. Features
      2. Class Library
        1. Classes and Hierarchy
          1. XElement Class
          2. XAttribute Class
          3. XDocument Class
          4. Other Classes
      3. LINQ to XML with Other XML Technologies
        1. LINQ with XmlReader
        2. LINQ with XSLT
          1. LINQ with MSXML
          2. Functional Construction
      4. XML Names
      5. Loading and Traversing XML
        1. Loading XML
        2. Traversing XML
      6. Data Manipulation
          1. Inserting or Adding Elements to XML
          2. Inserting or Adding XML Attributes
          3. Deleting XML
          4. Updating XML
          5. Deleting XML Attributes
          6. Updating XML Attributes
      7. Outputting and Streaming XML
        1. Streaming XML
      8. Querying XML
        1. Query Operators
        2. Queries
        3. Ancestors and Descendants
        4. XML Transformation
        5. Dictionaries´╗┐
          1. Convert Dictionary to XML
          2. Create Dictionary from XML
      9. Writing XML as Text Files and CSV Files
      10. Reading from CSV Files
      11. LINQ to XML Events
      12. XML Literals and Embedded Expressions in Visual Basic
      13. Summary
    9. 4. LINQ to SQL
      1. Working with Databases Using DataContext
      2. Entity Classes
        1. Attributes
          1. Database Attribute
          2. Table Attribute
          3. Column Attribute
          4. Association Attribute (Foreign Keys)
          5. Relationships
          6. Function Attribute
          7. Parameter Attribute
          8. Inheritance Mapping Attribute
      3. Creating and Deleting Databases
      4. DataContext Methods
      5. Data Manipulation
      6. LINQ to SQL Queries
        1. Identifying Objects
        2. Queries with Multiple Entities
          1. Remote Queries and Local Queries
          2. Deferred Loading
          3. Immediate Loading
          4. Projections
        3. Constructing XML
        4. Joins
        5. Raw SQL Query
        6. Query Result
        7. Stored Procedures
          1. User-Defined Functions
          2. Class Generator Tool
        8. Transactions
        9. Handling Concurrency Conflicts
      7. Object Relational Designer (O/R Designer)
      8. Summary
    10. 5. LINQ over DataSet
      1. Loading Data into DataSets
      2. Querying Datasets
      3. Sequence Operator
      4. Querying Typed DataSets
      5. DataSet Query Operators
        1. CopyToDataTable
        2. LoadDataRow
        3. Intersect
        4. Union
        5. Except
        6. Field<T>
        7. SetField<T>
      6. Projection
      7. Join
      8. SequenceEqual
      9. Skip
      10. Distinct
      11. Summary
    11. 6. LINQ to XSD
      1. Un-typed XML
      2. Typed XML
      3. Creating Typed XML using Visual Studio
        1. Object Construction
        2. Load Method
        3. Parse Method
        4. Save Method
        5. Clone Method
        6. Default Values
      4. Customization of XML Objects
        1. Mapping Time Customization
        2. Compile Time Customization
        3. Post Compile Customization
      5. Using LINQ to XSD at Command Line
      6. Summary
    12. 7. Standard Query Operators
      1. Restriction Operators
        1. Where
        2. OfType
      2. Projection Operators
        1. Select
        2. SelectMany
      3. Join Operators
        1. Join
        2. GroupJoin
      4. Concatenation Operator
          1. Concat
      5. Ordering Operators
      6. Set Operators
        1. Distinct
        2. Except
        3. Intersect
        4. Union
      7. Grouping Operators
        1. GroupBy
          1. ToLookup
      8. Conversion Operators
        1. AsEnumerable
        2. Cast
        3. OfType
        4. ToArray
        5. ToDictionary
        6. ToList
        7. ToLookup
      9. Equality Operators
        1. SequenceEqual
      10. Generation Operators
        1. Empty
        2. Range
        3. Repeat
      11. Quantifiers
        1. All
        2. Any
        3. Contains
      12. Aggregation Operators
        1. Average
        2. Count
        3. LongCount
        4. Min
        5. Max
        6. Sum
        7. Aggregate
      13. Partitioning Operators
        1. Take
        2. Skip
        3. TakeWhile
        4. SkipWhile
        5. TakeWhile
      14. Element Operators
        1. DefaultIfEmpty
        2. ElementAt
        3. ElementAtOrDefault
        4. First
        5. FirstOrDefault
        6. Last
        7. LastOrDefault
        8. Single
        9. SingleOrDefault
      15. List of Query Operators´╗┐
        1. Query Operator Equivalent Expressions
      16. Summary
    13. A. Building an ASP.NET Application
    14. B. LINQ with Outlook