left-icon

Getting the Most from LINQPad Succinctly®
by José Roberto Olivas Mendoza

Previous
Chapter

of
A
A
A

CHAPTER 1

A Quick Tour of LINQPad

A Quick Tour of LINQPad


What is LINQPad?

LINQPad is a free software utility developed by Joseph Albahari to be used as part of .NET application development. It’s used to interactively query SQL databases using LINQ, as well as to interactively write C# code without needing 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 dialects:

  • Entity Framework
  • LINQ to Objects
  • LINQ to SQL
  • LINQ to XML

There are several versions of the product; for the purposes of this book, we will focus on LINQPad 5 version 5.36.03, which is the current stable release at the time of writing.

LINQPad specifications

LINQPad offers a series of benefits to the user, such as:

  • Full support for C# 6 and later, and VB 14 in LINQPad 5.
  • Reporting of execution time in its status bar, allowing performance testing.
  • Cloning of code snippets with a keyboard shortcut (Ctrl+Shift+C), allowing their execution side by side.
  • Custom extension writing, which allows users to code methods and classes to make them available for all LINQPad queries.
  • Custom assembly referencing.
  • Building typed data contexts on the fly, including drivers and formatters for SQL Server, SQL Azure, SQLCE, Oracle, SQLite, and MySQL.
  • Object rendering with the embedded Dump method.
  • Access control for the Dump method in users’ custom types.
  • Full command-line experience with the lprun.exe utility.
  • Support for writing custom visualizers.
  • Support for presentation mode, allowing use of cordless presenter devices.

Note: A detailed explanation of LINQPad versions and other features can be found in my ebook LINQPad Succinctly.

Getting LINQPad 5

You can download LINQPad 5 here.

LINQPad 5 installation

Once you’ve downloaded LINQPad 5, double-click the setup program file LINQPad5Setup.exe to open it. For most users, this setup program can be found in the Downloads folder.

LINQPad Installation Program in User's Downloads Folder

Figure 1: LINQPad Installation Program in User's Downloads Folder

How LINQPad is deployed in user’s computer

After LINQPad is installed, a set of folders and files is created. These folders and files hold all the necessary elements that make LINQPad work properly, and are displayed in the following table.

Table 1: LINQPad folder structure.

Folder

Purpose

Documents\LINQPad Queries

Holds all queries created by the user. LINQPad uses this folder to display those queries in a tree view named My Queries.

Documents\LINQPad Plugins

Holds any custom assembly referenced by all or some queries.

Documents\LINQPad Snippets

Holds custom code snippets (doesn’t apply for free edition).

%LocalAppData%\LINQPad\drivers

Holds custom data context drivers which can be used in all queries.

%AppData%\LINQPad\ConnectionsV2.xml

Stores all connections that appear in the Connections tree view.

%AppData%\LINQPad\DefaultQuery.xml

Stores all assembly references that will be used by default in queries.

%AppData%\LINQPad\RoamingUserOptions.xml

Stores the user preferences that dictate LINQPad behavior.

Note: You can override the LINQPad default storage locations by creating a directory structure in the root install location of the LINQPad executable (which is C:\Program Files(x86)\LINQPad5 by default). For example, if you create a directory C:\Program Files(x86)\LINQPad5\Documents\LINQPad Queries and save queries there, when you ask LINQPad to open a query, it will search the new directory before searching the default directory.

LINQPad user interface

The LINQPad user interface is where you will do most of your work. For the purposes of this book, we’ll identify 14 graphic elements of this interface. These elements are:

  1. LINQPad File menu: Holds all available LINQPad commands for working with the program.
  2. Connection’s tree view area: Shows all connections created by the user with the connection manager.
  3. Queries and Samples tree view area: Shows all queries and extensions created by the user. It also shows all available samples within LINQPad, which are displayed in a separate tab.
  4. Query code tab window area: Where the user writes query code.
  5. Query code tab caption: Shows the name of the query being edited.
  6. Add New Tab button: Adds a new tab for query editing.
  7. Execute Query button: Executes the query that is currently selected.
  8. Stop Execution button: Stops query execution.
  9. Results View Type button: Allows the user to switch between Rich Text and Data Grid for viewing query results.
  10. Language Selector combo box: Allows the user to select the programming language in which queries will be written.
  11. Connection Selector combo box: Allows the user to select a previously created custom connection.
  12. Close Tab button: Closes the tab currently selected.
  13. Premium features activation link: In the free version of LINQPad, this link allows the user to open the product’s webpage to acquire a license for activating the paid license’s features.
  14. Status Bar: Shows several messages sent by the program, including query’s time performance.

LINQPad User Interface and Its Elements

Figure 2: LINQPad User Interface and Its Elements

LINQPad basics: Queries

LINQPad uses the term query for every piece of code that is written in the editor. So from now on, this word will be used within this book for pointing to every code sample displayed in it.

We can save every one of these pieces of code for future use. By default, queries are saved in the LINQPad Queries folder located in the current user’s Documents folder. Also, after a query is saved, its name appears in the Queries and Samples tree view area of the user interface.

A LINQPad Query in the Queries and Samples Tree View Area

Figure 3: A LINQPad Query in the Queries and Samples Tree View Area

Setting up the queries and external projects location

For the purposes of this book, every query written in LINQPad will be saved in a folder named LINQPad Samples. In my case, this folder will be located at D:\, but you can place this folder in any convenient directory.

Chapter summary

LINQPad is a software utility developed by Joseph Albahari 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.

LINQPad supports the VB.NET, SQL, and F# languages. It also supports Entity Framework, LINQ to Objects, LINQ to SQL, and LINQ to XML dialects.

There are several versions of LINQPad, but for the purposes of this book, we will focus on the LINQPad 5 free version 5.36.03, which is the latest stable version according to the product’s website at the time of this writing.

LINQPad 5 can be downloaded here.

LINQPad 5 can be installed by downloading the product from the LINQPad website and double-clicking the setup program’s icon. Most users can find the installation program file in the Downloads folder.

After LINQPad is installed, a set of folders and files is created in order to make sure LINQPad works properly. These folders and files hold all elements needed by LINQPad, such as queries, plugins, code snippets, data context drivers, connections, default references, and user preferences.

The LINQPad user interface is where you will do most of your work. We have identified fourteen graphic elements in the LINQPad user interface for the purposes of this book. These elements are: the LINQPad main menu, Connection’s tree view area, Queries and Samples tree view area, Query code tab window area, Query code tab caption, Add New Tab button, Execute Query button, Stop Execution button, Results View Type button, Language Selector combo box, Connection Selector combo box, Close Tab button, Premium Features activation link, and Status Bar.

LINQPad uses the term query for every piece of code that is written in the editor and allows us to save this code onto disk. LINQPad stores queries in a folder named LINQPad Queries by default, located into the user’s Documents folder. All queries saved are displayed beneath a tree view node called My Queries.

For the purposes of this book, every query written in LINQPad will be saved in a folder named LINQPad Samples.

Scroll To Top
Disclaimer
DISCLAIMER: Web reader is currently in beta. Please report any issues through our support system. PDF and Kindle format files are also available for download.

Previous

Next



You are one step away from downloading ebooks from the Succinctly® series premier collection!
A confirmation has been sent to your email address. Please check and confirm your email subscription to complete the download.