Explore LINQPad: A Dev’s Swiss Army Knife

Sheldon Cohen
3 min readJul 25, 2023

So you’re a seasoned developer juggling different tasks on your busy day. One minute, you’re running some SQL queries, the next you’re trying to test out a piece of .NET code, and the minute after, you’re debugging a complex LINQ query. Wouldn’t you just love to have one tool that does it all? A multifaceted Swiss Army Knife, so to speak, for your developer needs. Enter LINQPad, your new best friend in the realm of .NET.

LINQPad logo

What is LINQPad?

Imagine a world where the power of the richest Integrated Development Environments (IDEs) meets the simplicity of a notepad. That’s LINQPad in a nutshell. Named after the Language-Integrated Query (LINQ), this lightweight yet powerful tool is the Swiss Army Knife that simplifies the life of developers who breathe .NET.

Querying TimeZoneInfo

Let’s take a simple use case: you’re developing an international software product and need to test the conversion between various time zones. Now, isn’t it a pain to write a whole console application just for that? With LINQPad, it’s as easy as slicing through butter.

Just type the following into LINQPad’s code window:


void Main()
{
var timeZoneInfo = TimeZoneInfo.FindSystemTimeZoneById("America/New_York");
timeZoneInfo.Dump();
}

Hit Execute, and LINQPad presents you with nicely formatted data about your TimeZoneInfo.

TimeZoneInfo displaying it’s data formatted

Integrating with SQLite: The Chinook Sample Database

The SQL query capabilities of LINQPad can truly shine when you pair it with a more comprehensive dataset. Let’s use the popular sample database, “Chinook”, which simulates a digital media store, including tables for artists, albums, media tracks, invoices, and customers.

To add your connection, you can simply:

1. Click ‘Add connection’ in LINQPad.
2. Choose ‘Build data context automatically’ and select the SQLite Driver.
3. Enter the path of your SQLite database file.
4. Click ‘OK’ to add the connection.

Chinook database tables

Once the connection is established, you can try some LINQ queries. Let’s say you want to find out the top 10 tracks in your media store, based on the number of times they’ve been sold.

To get this data, run the following LINQ query:

Tracks
.GroupJoin(
InvoiceLines,
track => track.TrackId,
line => line.TrackId,
(track, lines) => new { Track = track.Name, Sales = lines.Count() }
)
.OrderByDescending(t => t.Sales)
.Take(10)
Top ten tracks from chinook database

Wrapping Up

LINQPad provides power, flexibility, and ease of use. It’s the tool you never knew you needed, but once you have it, you’ll wonder how you ever lived without it. Just like that Swiss Army Knife you take on all your wilderness adventures. So why not take LINQPad for a spin?

Whether you’re querying time zones or fetching data from a SQLite database, LINQPad is like your genie that says, “Your wish is my command”. No fuss, no drama, just simple, powerful functionality.

Have some feedback, or follow up, leave a comment!

Sign up to discover human stories that deepen your understanding of the world.

Free

Distraction-free reading. No ads.

Organize your knowledge with lists and highlights.

Tell your story. Find your audience.

Membership

Read member-only stories

Support writers you read most

Earn money for your writing

Listen to audio narrations

Read offline with the Medium app

Sheldon Cohen
Sheldon Cohen

Written by Sheldon Cohen

Technology professional with 15+ years of software development

No responses yet

Write a response