You are previewing Building Interactive Queries with LINQPad.
O'Reilly logo
Building Interactive Queries with LINQPad

Book Description

Learn how to query databases interactively using LINQ and LINQPad

  • Leverage the power of LINQPad to learn LINQ

  • Discover LINQPad’s key features and options

  • Learn about the cool applications of LINQPad such as testing, code snippet generation, and so on

In Detail

If you need to interact with databases, XML, in-memory collections, or remote services, LINQ can make your life simpler. The best way to discover LINQ is with the help of LINQPad, a free IDE whose first goal is to make sure that writing and interacting with your LINQ query is fun and easy. More generally, LINQPad is a C#/VB/F# scratchpad that instantly executes any expression, statement block, or program with rich output formatting and a wealth of features.

With Building Interactive Queries with LINQPad, you will quickly learn everything you need to know to start using LINQ. To accelerate your learning curve, you will discover how to use LINQPad and its features to test your queries interactively and experiment with all the options offered by LINQ.

In all probability, you already know C#, but have you had a chance to try out LINQ? Building Interactive Queries with LINQPad will introduce you to everything LINQ can offer and will let you interact with every example in LINQPad, LINQ’s best companion.

You will learn how to build and experiment with interactive queries with this practical guide illustrated with short and detailed code samples. You will also get acquainted with other cool applications of LINQpad such as testing, code snippet generation, and so on, along with a broad approach to LINQ (to object, to SQL, to XML, and so on).

Table of Contents

  1. Building Interactive Queries with LINQPad
    1. Table of Contents
    2. Building Interactive Queries with LINQPad
    3. Credits
    4. About the Author
    5. About the Reviewers
    6. www.PacktPub.com
      1. Support files, eBooks, discount offers and more
        1. Why Subscribe?
        2. Free Access for Packt account holders
        3. Instant Updates on New Packt Books
    7. Preface
      1. What this book covers
      2. What you need for this book
      3. Who this book is for
      4. Conventions
      5. Reader feedback
      6. Customer support
        1. Downloading the example code
        2. Errata
        3. Piracy
        4. Questions
    8. 1. Discovering LINQPad
      1. Downloading and installing LINQPad
        1. Editions available
      2. Look and feel of LINQPad
        1. The File menu
        2. The Edit menu
        3. The Query menu
        4. The Help menu
      3. Configuring LINQPad
        1. The Editor tab
        2. The Query tab
        3. The Results tab
        4. The Folders tab
        5. The Web proxy tab
        6. The Advanced tab
      4. Summary
    9. 2. Coding in LINQPad
      1. Writing your first LINQPad query
      2. Query types
        1. The C#/F#/VB expression
        2. The C# and VB statement
        3. The C#, F#, and VB programs
        4. SQL/ESQL
      3. Referencing additional assemblies
        1. Adding it manually
        2. Adding it with NuGet
      4. Referencing additional namespaces
      5. LINQPad's Dump() method
      6. Summary
    10. 3. Learning LINQ's Basics
      1. The fundamentals of LINQ
      2. The purpose of LINQ
      3. A LINQ query
        1. The standard version
        2. The LINQ version
        3. Query operators
        4. Chaining calls
      4. One LINQ, two syntaxes
      5. Summary
    11. 4. Discovering LINQ Query Operators
      1. Defining LINQ to objects
      2. Query operators
        1. Quantifier operations
          1. The Any() query operator
          2. The All() query operator
          3. The Contains() query operator
        2. Filtering operations
          1. The Where() query operator
          2. The OfType() query operator
        3. Sorting operations
          1. The OrderBy() and OrderByDescending() query operators
          2. The ThenBy() and ThenByDescending() query operators
          3. The Reverse() query operator
        4. Partitioning operations
          1. The Take() and TakeWhile() query operators
          2. The Skip() and SkipWhile() query operators
      3. Summary
    12. 5. Database and Relational Data
      1. Introducing LINQ to SQL
        1. Setting up a database
        2. Adding a connection to LINQPad
      2. Interacting with the database
        1. Looking into the categories
        2. Filtering the categories
      3. Element operations
        1. The First() and FirstOrDefault() query operators
        2. The Single() and SingleOrDefault() query operators
        3. The Last() and LastOrDefault() query operators
        4. The ElementAt() and ElementAtOrDefault() query operators
      4. Conversion operations
        1. The ToArray() and ToList() query operators
        2. The ToDictionary() and ToLookup() query operators
      5. Deferred execution
      6. Grouping operations
        1. The GroupBy() query operator
      7. Working with relational data
        1. Interactive navigation with LINQPad
      8. Projection operations
        1. The Select() query operator
        2. The SelectMany() query operator
      9. Inserting, updating, and deleting data
        1. Adding a new entry to the database
        2. Updating entries from the database
        3. Deleting data from the database
      10. Views and Stored Procedures
      11. Acknowledging LINQ to SQL limits
      12. Summary
    13. 6. Using Other Data Sources
      1. Handling XML
        1. Creating and querying an XML fragment
        2. Aggregation operations
          1. The Average() and Sum() query operators
          2. The Max() and Min() query operators
          3. The Count() and LongCount() query operators
        3. Using XPath
        4. Other operations
      2. Discovering Entity Framework
        1. Setting up the context
        2. Running your first Entity Framework query
        3. Join operations
          1. The Join() query operator
          2. The GroupJoin() query operator
      3. Interacting with WCF Data Services
        1. Adding a connection to a service
        2. Making your first request to the service
      4. Summary
    14. 7. Getting More Out of LINQPad
      1. Customizing LINQPad
        1. Customizing the results pane
        2. Writing a custom visualizer
      2. SQL querying
      3. Exporting data
      4. Searching your queries
      5. Leveraging the Util class
      6. Summary
    15. Index