You are previewing Introducing Microsoft® LINQ.
O'Reilly logo
Introducing Microsoft® LINQ

Book Description

Get a head start on using the Microsoft Language Integrated Query (LINQ) Project with advance insights from two experienced developers. Data-rich applications can be difficult to create because of the tremendous differences between query languages used to access data and programming languages commonly used to write applications. This practical guide introduces LINQ, a set of extensions to the Microsoft Visual C#® and Microsoft Visual Basic® programming languages. Instead of traversing different language syntaxes required for accessing data from relational and hierarchical data sources, developers will learn how to write queries natively in C# or Visual Basic. Written by two experienced developers with strong ties to Microsoft’s developer teams, this book introduces the LINQ architecture and classes, describes the new language features in both C# and Visual Basic, and provides code samples in both languages.

Table of Contents

  1. Copyright
    1. Dedication
  2. Acknowledgments
  3. Introduction
    1. About This Book
    2. System Requirements
    3. Support for This Book
  4. 1. LINQ Introduction
    1. What Is LINQ?
      1. How LINQ Works
      2. Relational Model vs. Hierarchical/Graph Model
      3. XML Manipulation
    2. Language Integration
      1. Declarative Programming
      2. Type Checking
      3. Transparency Across Different Type Systems
    3. LINQ Flavors
      1. LINQ to Objects
      2. LINQ to ADO.NET
      3. LINQ to XML
    4. Present State and Future Direction of LINQ
    5. Summary
  5. 2. C# Language Features
    1. C# 2.0 Revisited
      1. Generics
      2. Delegates
      3. Anonymous Methods
      4. Enumerators and Yield
    2. C# 3.0 Features
      1. Local Type Inference
      2. Lambda Expressions
      3. Extension Methods
      4. Object Initialization Expressions
      5. Anonymous Types
      6. Query Expressions
    3. Summary
  6. 3. Visual Basic 9.0 Language Features
    1. Visual Basic 9.0 and Nullable Types
    2. Visual Basic 9.0 Features Corresponding to C# 3.0
      1. Local Type Inference
      2. Extension Methods
      3. Object Initialization Expressions
      4. Anonymous Types
      5. Query Expressions
      6. Lambda Expressions
      7. Closures
    3. Visual Basic 9.0 Features Without C# 3.0 Counterparts
      1. XML Support
        1. XML Literals
        2. Late Binding over XML
      2. Relaxed Delegates
    4. C# 3.0 Features Without Visual Basic 9.0 Counterparts
      1. The yield Keyword
      2. Anonymous Methods
    5. Summary
  7. 4. LINQ Syntax Fundamentals
    1. LINQ Queries
      1. Query Syntax
      2. Full Query Syntax
    2. Query Operators
      1. The Where Operator
      2. Projection Operators
        1. Select
        2. SelectMany
      3. Ordering Operators
        1. OrderBy and OrderByDescending
        2. ThenBy and ThenByDescending
        3. Reverse Operator
      4. Grouping Operators
      5. Join Operators
        1. Join
        2. GroupJoin
      6. Set Operators
        1. Distinct
        2. Union, Intersect, and Except
      7. Aggregate Operators
        1. Count and LongCount
        2. Sum
        3. Min and Max
        4. Average
        5. Aggregate
      8. Generation Operators
        1. Range
        2. Repeat
        3. Empty
      9. Quantifiers Operators
        1. Any
        2. All
        3. Contains
      10. Partitioning Operators
        1. Take
        2. TakeWhile
        3. Skip and SkipWhile
      11. Element Operators
        1. First
        2. FirstOrDefault
        3. Last and LastOrDefault
        4. Single
        5. SingleOrDefault
        6. ElementAt and ElementAtOrDefault
        7. DefaultIfEmpty
      12. Other Operators
        1. Concat
        2. SequenceEqual
    3. Deferred Query Evaluation and Extension Methods Resolution
      1. Deferred Query Evaluation
      2. Extension Methods Resolution
    4. Conversion Operators
      1. AsEnumerable
      2. ToArray and ToList
      3. ToDictionary
      4. ToLookup
      5. OfType and Cast
    5. Summary
  8. 5. LINQ to ADO.NET
    1. LINQ to SQL
      1. Entities in LINQ to SQL
      2. Data Modeling
        1. DataContext
        2. Entity Classes
        3. Entity Inheritance
        4. Unique Object Identity
        5. Entity Constraints
        6. Associations Between Entities
          1. EntityRef
          2. EntitySet
          3. Other Association Attributes
          4. Graph Consistency
          5. Change Notification
        7. Relational Model vs. Hierarchical Model
      3. Data Querying
        1. Projections
        2. Stored Procedures
        3. User-Defined Functions
        4. Compiled Queries
        5. Different Approaches to Querying Data
        6. Direct Queries
        7. Read-Only DataContext Access
      4. Data Update
        1. Entity Updates
        2. Database Updates
        3. Concurrent Operations
        4. Transactions
        5. Stored Procedures
      5. Binding Metadata
        1. Creating a Database from Entities
        2. Creating Entities from a Database
        3. External Mapping
      6. Differences Between .NET and SQL Type Systems
    2. LINQ to DataSet
      1. Using LINQ to Load a DataSet
      2. Using LINQ to Query a DataSet
      3. Using LINQ to Query a Typed DataSet
      4. Accessing Untyped DataSet Data
    3. LINQ to Entities
    4. Summary
  9. 6. LINQ to XML
    1. Introducing LINQ to XML
    2. LINQ to XML API
      1. XElement
      2. XDocument
      3. XAttribute
      4. XNode
      5. XName and XNamespace
      6. Other X* Classes
      7. XObject and Annotations
    3. Reading, Traversing, and Modifying XML
    4. LINQ to XML Queries
      1. Attribute, Attributes
      2. Element, Elements
      3. XNode Selection Methods
      4. Similarities Between XPath Axes and Extension Methods
      5. InDocumentOrder
    5. Deferred Query Evaluation
    6. Using LINQ Queries over XML
    7. Support for XSD and Validation of Typed Nodes
    8. Support for XPath and System.Xml.XPath
    9. Summary
  10. ADO.NET Entity Framework
    1. ADO.NET Standard Approach
    2. Abstracting from the Physical Layer
    3. Entity Data Modeling
    4. Querying Entities with ADO.NET
    5. Querying ADO.NET Entities with LINQ
    6. Changing and Updating ADO.NET Entities
    7. LINQ to SQL and ADO.NET Entity Framework
    8. Summary
  11. About the Authors
  12. Additional Resources for Developers
    1. Visual Basic 2005
    2. Visual C# 2005
    3. Web Development
    4. Data Access
    5. SQL Server 2005
    6. Other Developer Topics
  13. More Great Developer Resources
    1. Developer Step by Step
    2. Developer Reference
    3. Advanced Topics