CHAPTER 1
LINQPad is a software utility developed by Joseph Albahari, and it’s intended to be used as a part of .NET application development. It is used for interactively querying SQL databases using LINQ, as well as interactively writing C# code without the need for an IDE (such as Visual Studio). This feature expands its use as a “test tool” where C# code can be quickly prototyped outside the IDE. It also supports the VB.NET, SQL, and F# languages. LINQPad supports the following technologies:
The product starts with a freemium version, which lacks an autocomplete feature for the C# language. To get this feature, the user should purchase a commercial license.
Regardless of the type of license, either free or commercial, there are three versions of the product:
Note: LINQPad 5 can run side-by-side with LINQPad 4.
There are four editions for the LINQPad product: Free, Pro, Developer, and Premium. Except for the first one, the user will need to pay a license fee for using the product. Depending on which edition is purchased, LINQPad unlocks a series of additional features to those included in the free edition. The user installs the free edition of LINQPad first, then buys a license for upgrading to the desired edition beyond the free one. This license applies for both LINQPad 4 and LINQPad 5, so the user doesn’t need to pay a fee for each version.
Note: According to the product’s website, the users who purchased a license of LINQPad 4 prior January 1, 2015 must purchase an upgrade to LINQPad 5.
The following table summarizes all features available for LINQPad, in accordance with the edition being used.
Table 1: LINQPad Editions Comparison Table
Edition | ||||
|---|---|---|---|---|
Features | Free | Pro | Developer | Premium |
Run LINQ queries or any C#/VB/F# expression/program | Yes | Yes | Yes | Yes |
Results output to rich text or data grids | Yes | Yes | Yes | Yes |
Automatic translation to SQL, fluent-lambda, and IL | Yes | Yes | Yes | Yes |
Reference user’s own assemblies, plus the entire .NET Framework | Yes | Yes | Yes | Yes |
Use of custom extensions, visualizers, and data source providers | Yes | Yes | Yes | Yes |
Full C#/F#/VB autocompletion and tooltips | Yes | Yes | Yes | |
Smart tags for importing additional namespaces/references (C#/VB) | Yes | Yes | Yes | |
Code outlining and auto-formatting (C#/VB) | Yes | Yes | Yes | |
Rename symbol, go to definition and find references (C#/VB) | Yes | Yes | Yes | |
Built-in and custom code snippets | Yes | Yes | ||
Cross-database querying for SQL Server | Yes | Yes | ||
Directly edit SQL data in grids and save changes back to database | Yes | Yes | ||
Full NuGet integration | Yes | Yes | ||
Integrated debugger, with call stack, threads, local variables/watch windows, breakpoints and single-stepping | Yes | |||
LINQPad offers a series of benefits to the user, such as:
LINQPad is a client/server application that works in an unusual way. While most client/server applications have many clients and one server, with LINQPad, there is one client and there are many servers. In this case, the LINQPad user interface is the client as expected, and for each query that is going to be executed, LINQPad creates a separate server, which has a class that runs in its own process. This process runs the query in isolation. The isolation prevents queries from interfering with each other or with the user interface, and it allows LINQPad to safely cancel a query without affecting other application domains.
LINQPad uses a customized communications layer that runs atop Windows shared memory, providing a faster, more reliable, and fully asynchronous communications layer.
Microsoft Roslyn libraries are used to compile queries in LINQPad 5. Regarding database objects, LINQPad needs a typed DataContext for backing any database object referenced in queries, because C# and VB are statically typed. LINQPad builds these typed DataContexts on the fly by using Reflection.Emit instead of generating and compiling source code, for performance reasons. Also, it uses LINQ to SQL rather than Entity Framework because LINQ to SQL is lighter and faster in building meta models when instantiated.
LINQPad's emission engine itself runs in a separate application domain, because Reflection.Emit must instantiate types in memory whose assemblies cannot be unloaded. This domain is regularly refreshed to avoid an ever-increasing memory footprint.
So much of LINQPad’s work goes on in the background, such as querying database schemas, emitting typed DataContexts, and compiling and executing queries. For this reason, every potentially time-intensive feature operates asynchronously to maintain a responsive user interface.
LINQPad’s Dump method (which will be discussed later) feeds the output into an XHTML stream. This stream is displayed using an embedded web browser (the user can notice this by right-clicking a query result and choosing View Source). LINQ to XML is used to transform the output into XHTML as one LINQ query. The deferred expansion of results and fetching of additional data when the user clicks on hyperlinks is made via JavaScript.
LINQPad uses third-party libraries from several software publishers. These include Actipro’s SyntaxEditor, the SharpDevelop project, Microsoft Roslyn, and NRefactory. The libraries from these publishers are included as embedded resources in LINQPad, so it ships as a single executable.
All updates for LINQPad are downloaded into the application’s data folder. Then, LINQPad checks that the new assembly has the same strong name. If so, LINQPad forwards to that executable, which then writes itself back to the original one. This operation can fail, depending on the permissions given to the folder where LINQPad was downloaded. Every time it’s started, LINQPad always checks to see if there’s a later, signed version of itself in the application’s data folder.

Figure 1: Context diagram about how LINQPad works
LINQPad is a software utility developed by Joseph Albahari, and it’s intended to be used as a part of .NET application development. It is used to interactively query SQL databases using LINQ, as well as to interactively write C# code without the need for an IDE, such as Visual Studio.
LINQPad supports VB.NET, SQL, and F# languages. Also, LINQPad supports Entity Framework, LINQ to Objects, LINQ to SQL, and LINQ to XML dialects.
The product starts with a freemium version, which lacks several features, such as autocomplete for the C# language. Regardless of the type of license, free or commercial, there are three versions for the product: LINQPad 2.x (for .NET Framework 3.5), LINQPad 4 (for .NET Framework 4.0/4.5), and LINQPad 5 (for .NET Framework 4.6). Also, there are four editions for each one of these versions: Free, Pro, Developer, and Premium.
Depending on which version is purchased, LINQPad automatically enables extra features above all those included in the free version. Some of these features include Full C#/F·/VB autocompletion and tooltips, code outlining and formatting for C#/VB, built-in and custom code snippets, and full NuGet integration.
LINQPad is a client/server application, which works as one client and many servers. In this case, the LINQPad user interface is the client, as expected, and for each query that is going to be executed, LINQPad creates a separate server. For communications between client and servers, LINQPad uses a customized communications layer that runs atop Windows shared memory.
Microsoft Roslyn libraries are used to compile queries in LINQPad 5. All database objects are backed by using typed DataContexts, because C# and VB are statically typed. All DataContexts are built on the fly by using Reflection.Emit. LINQPad uses LINQ to SQL rather than Entity Framework. All background work (querying database schemas, compiling and executing queries) operates asynchronously, in order to maintain a responsive user interface.
LINQPad uses third-party libraries from several software publishers within the UI. These includes Actipro’s SyntaxEditor, the SharpDevelop project, Microsoft’s Roslyn, and NRefactory. The libraries from these are included as embedded resources in LINQPad, so it ships as a single executable.
All updates for LINQPad are downloaded into the application’s data folder. Every time it’s started, LINQPad checks to see if there’s a later, signed version of itself in the application’s data folder.