Skip to content

LINQPad is Totally Awesome at Testing and Writing LINQ Queries

Updated: at 02:12 PM

http://www.linqpad.net/ - Use with Microsoft .Net for building Query type expressions with LINQ

I'm not a wizard at writing LINQ expressions so I often find myself in Google looking for something similar to what I want, then I put it into my application and run it. This has worked pretty well, but it takes a couple iterations to get it right. It occured to me that someone probably has written a LINQ interpreter so I just guessed the name, LINQPad, typed it into search, and I find the authors of the book C# 3.0 in a nutshell, Joseph Albahari and Ben Albahari, (which I like a lot) have written it.

I download it (it's an exe file), run it (OK, I trust you guys somehow), and presto, I get a very nice interface that not only has tons of examples built into it with a nice tree view, but lets me make a connection to my database and run LINQ queries against it. It even cancels them when you create one that will run forever (very nice guys!).

So, the query I was going after is I have a huge list of cities that includes states. From that, I just want a unique list of states (this list does not have all the states so I want just the ones contained in it). Below is a screen shot of the LINQPad with my Query in it. I simply pressed the green triangle (trained by Sql Server Enterprise Manager), and presto, my list! Could not be much easier. This tool will be in my box for a long time.

 

image

 

Grab this now!  It's a winner, believe me.

Check out the ORM (Object Relational Mapper) PRISMA. The database access method I use in all my projects