Exercise Your LINQ Queries With LINQPad

linqpad Here’s a great tool available for free, whether you’re starting out with LINQ for the first time, or whether you’re looking for a better way to write and test your LINQ queries. Written by Joseph Albahari, co-author of C# 3.0 In a Nutshell, LINQPad is a simple visual editor from which you can write LINQ queries against a database and by clicking on a button (or pressing F5) it’ll generate a visual/graphical output of the result. The tool itself is very small (2MB), self-updating and ready to execute (no need to install it). You’ll need to make sure that Microsoft .NET Framework 3.5 is installed before using it. If you have installed Visual Studio 2008 or Visual Studio 2008 Express Edition, then you have what it takes to run the tool.

LINQPad gives you the freedom to use C#, VB or SQL statements to write your LINQ query and offers you the choice between running it against a specific database or not (in case you want to run LINQ with your objects in memory).

For instance, the following screenshot shows you the output from a C# LINQ query:


Click to see larger image

Specifying a database connection (to target the query against) is very easy if you’re somewhat familiar with setting up database connections in SQL Server. All you need to do is click on the ‘Add connection‘ link on the left pane of the main window and fill in the connection properties. You can also test the connection properties, but there is a twist in the story: you’d expect a message dialog box to pop up telling you whether the connection was successful or not. In reality, the status of the connection is on the window’s title bar. Note that if, for some reason, the connection can’t be established, a message box will appear showing you the cause of the error.

Fill in the properties and click on 'Test' Verify the status of the connection

Now you have one less reason NOT to play around with LINQ ;)

This post has been viewed: 609 times. kick it on DotNetKicks.com

 

Similar posts you might be interested in reading:

Leave a comment

Powered by WP Hashcash