Featured image of post LINQPad in a Nutshell

LINQPad in a Nutshell

LINQPad in a Nutshell

LINQPad in a Nutshell

A Little History

Once upon a time (2007, to be exact), a hero named Joe Albahari looked at the world of .NET development and thought, Why is running a simple LINQ query harder than it needs to be? And so, LINQPad was born.

Initially, it was just a handy way to test LINQ queries. But over time, it evolved into a full-fledged C# scratchpad, supporting LINQ, SQL, and even full-blown C# programs. Think of it as Notepad for .NET—except way cooler and significantly more useful.

Why Should You Care?

Because LINQPad is awesome. It lets you:

  • Write and test LINQ queries instantly.
  • Query databases without setting up a massive project.
  • Execute C# code on the fly.
  • Explore and interact with your EF Core or SQL databases like a boss.
  • Use Dump() to output results in a way that actually makes sense.

And the best part? No need to open Visual Studio and wait while your coffee gets cold.

Getting Started with LINQPad

  1. Download LINQPad from linqpad.net.
  2. Install it (this part is surprisingly easy).
  3. Open it and start writing queries.

Boom! You’re now 10x more productive than you were five minutes ago.

Code Examples

1. Running a Simple LINQ Query

1
2
3
4
5
6
void Main()
{
    var numbers = Enumerable.Range(1, 10);
    var evens = numbers.Where(n => n % 2 == 0);
    evens.Dump(); // LINQPad's magic output method
}

2. Querying a Database

1
2
3
4
5
void Main()
{
    var db = new Query("SELECT * FROM Customers");
    db.Dump();
}

3. Writing a Quick C# Script

1
2
3
4
5
void Main()
{
    Console.WriteLine("Hello, LINQPad!");
    "Hello, LINQPad!".Dump(); // The LINQPad way
}

4. Using Entity Framework Core

1
2
3
4
5
6
void Main()
{
    var ctx = new MyDbContext();
    var users = ctx.Users.Where(u => u.IsActive).ToList();
    users.Dump();
}

Why Dump() is Life-Changing

Forget Console.WriteLine(). LINQPad’s Dump() method is what every C# developer has dreamed of. It takes any object and displays it in a beautifully formatted way—tables, graphs, JSON, whatever makes sense.

The Paid Version: Is It Worth It?

LINQPad comes in a free version that does almost everything you need. But if you want auto-completion and advanced features, the paid version is a no-brainer. Seriously, if you use LINQPad regularly, just buy it. Joe Albahari deserves a coffee.


Key Ideas

TopicSummary
HistoryCreated by Joe Albahari in 2007 to simplify LINQ queries.
FeaturesSupports LINQ, SQL, C# scripting, and EF Core.
BenefitsNo need for Visual Studio; quick and easy testing of queries.
Code ExamplesDemonstrates LINQ queries, database interaction, and scripting.
Dump()The magical method that makes debugging easy.

References