BT

Facilitating the Spread of Knowledge and Innovation in Professional Software Development

Write for InfoQ

Topics

Choose your language

InfoQ Homepage News Master LINQ with LINQPad

Master LINQ with LINQPad

Leia em Português

This item in japanese

LINQPad is a free standalone application written by Joseph Albahari as an add-on for his C# 3.0 in a Nutshell.

LINQPad is fundamentally a LINQ interpreter with an IDE and SQL integration built around it. LINQPad has a simple but powerful user interface allowing immediate execution of LINQ expressions, including multi-statement snippets of LINQ to SQL, LINQ to Objects, and LINQ to XML.

LINQPad UI

LINQPad offers several execution modes:

  • C# (or VB) Expression
  • A single C# or VB.NET LINQ expression is executed, and the resulting object is displayed in the results window.
  • C# (or VB) Statement(s)
  • An arbitrary number of LINQ expressions can be executed. LINQPad has a Dump extension method defined to send objects and text to the results window during execution.
  • C# (or VB) Program
  • Execution context is placed within a Main() method, allowing definition of other classes and methods inside LINQPad editor to support testing.
  • SQL
  • Provides ad-hoc querying of data using SQL.

It's important to remember that LINQPad will execute any C# (or VB.NET) code statements, not just LINQ expressions. This means LINQPad is useful for any code snippet needing simple testing, e.g., tricky numeric format strings or Regex matching.

 

LINQPad comes with numerous sample LINQ expressions that show the nuances and power of LINQ, covering beginner examples along with more advanced concepts like deferred execution and projection. LINQPad also has a helpful learning feature that presents various options for viewing results:

  • Default results view
  • A simple graphical representation of the objects and text returned from statements
  • Lambda view
  • LINQ expressions translated into lambda expressions, if applicable
  • SQL view
  • LINQ expressions translated into SQL, if applicable
  • IL view
  • Microsoft Intermediate Language generated for code statements

 

LINQPad provides extensibility by allowing users to reference custom assemblies and import custom namespaces. LINQ to Entities can be supported through this extensibility.

Beyond a learning and testing tool, LINQPad is growing in popularity as a utility to perform ad-hoc queries against a SQL database.

Simple LINQ to SQL expression output to results view: 

LINQPad LINQ to SQL

Simple LINQ to SQL expression output to lambda view: 

LINQ to SQL - lambda view

Simple LINQ to SQL expression output to SQL view: 

LINQ to SQL - SQL view

LINQPad is free and self updating. Intellisense is now available but only included in the $19 licensed version. LINQPad does not require Visual Studio but does require .NET Framework 3.5.

Rate this Article

Adoption
Style

BT