LINQPad – A free stand-alone LINQ editor/tester created by Joseph Albahari, author of C# 3.0 in a Nutshell. LINQPad is like SQL Query Analyzer, but for LINQ.
One of the major additions to the Microsoft .NET Framework 3.5 is LINQ, a set of classes and language enhancements designed to offer a universal data-querying syntax. With LINQ to Objects, LINQ to XML, and LINQ to SQL, you can query arrays and collections, XML documents, and database tables using a similar syntax with rich features like IntelliSense and compile-time type checking. LINQ syntax, however, can be downright confusing for developers who have spent the better part of their programming careers using SQL to query data.
LINQPad’s user interface is divided into four panes. The upper-left pane presents a list of database servers, which you can drill into to view the databases and their tables, views, and stored procedures. To test a LINQ query, type it into the top-right pane. You can enter a LINQ query directly or type in the C# or Visual Basic code that executes a LINQ query. When writing and testing LINQ to SQL queries, you can select the database from the upper-left pane to query against.
The bottom-right pane displays the results of the query. There are three views: the results, the corresponding lambda expression, and an equivalent SQL statement. The bottom-left pane serves as a workspace to organize your frequently used queries. This pane also includes a Samples tab with more than 200 C# and Visual Basic LINQ examples from Albahari’s book, C# 3.0 in a Nutshell (O’Reilly, 2007). For those new to LINQ, these examples are invaluable learning tools, as is the ability to view the LINQ query’s equivalent SQL statement.
You can think of LINQPad as a scaled-down, LINQ-based implementation of SQL Server®Management Studio. When writing a SQL query to display data in an application, it is usually easier to write the query in Management Studio and then copy and paste it into your code in Visual Studio than it is to write the query from scratch in Visual Studio. This is due to the fact that testing the query from Visual Studio requires running the application. Much in the same manner, I find it easier to write and test my LINQ queries in LINQPad.
While the LINQPad editor color codes keywords, variables, strings, and comments and underlines errors with red or blue squiggly lines just as Visual Studio does, it does not yet support IntelliSense. (This is a planned future enhancement.) Despite the lack of IntelliSense, LINQPad’s intuitive and lightweight user interface, its many features, and the plethora of examples make it an excellent tool for learning, writing, and testing LINQ queries.