LINQPad – Query Analizer for Linq

There’s an awesome tool called LINQPad by Joseph Albahari – completely free, download here.  (“LINQPad is not an open-source product and the source code is protected by standard copyright laws.  Nonetheless, you are free to disassemble the executable to satisfy your curiosity…” says the author.) 

It’s billed as the Query Analyzer for Linq to Sql.  It does wonders for giving you a quick chance to mock up some Linq to Sql.  It is an awesome product for getting you into Linq, but it seems to fall short of it’s full potential.

What it does really well:

– Get you to think in LINQ – because you’re typing LINQ instead of SQL, you’ll get good at LINQ instead of SQL – that’s the goal now-a-days, right?  (: As soon as I get good at == instead of = and && instead of and, I’ll let you know… :)

– Quickly mock up some Linq to Sql and see what the answer is.  Discover data, harvest a quick table of results.  The results window is html, so if all you need is the table, copy-paste it into place, and say thank you.

– Samples a plenty – It’s hard to know how much I need to type in here.  Do I need a using ( MyDbDataContext db = new MyDbDataContext() ) { ?  What is the data context’s variable name?  It turns out LINQPad does all the data context creation behind the scenes, and I only need to spit out the Linq, referencing the tables by name – very nice.  I wouldn’t have figured that out on my own without the Samples tab in the bottom-left pane so eager to greet me.  Many thanks for making that so easy to stumble onto.

– The interface is very well thought out, and very elegant.  Select a db in the same place as I would in Sql Management Studio – the toolbar on the top.  Browse the databases, tables, and fields in a tree-view as I would in Sql Management Studio.  I can have multiple tabs of queries.  F5 is the shortcut to run the query.  I can look at the raw sql executed by clicking on the [SQL] button above the results pane.  Right-click on a table, and get some sample queries prebuilt for you.  Icons are natural fits.  It is very clean and elegant.  It makes me want to hire Joseph to do interface design.

There are some short-falls though that make it not as effective as it could be:

– No intelisense – the author is very specific about not liking intelisense.  I’m all for freedom of speech and the right to bear arms and legs, but I code faster with intelisense than without.  Yes, I’ve tried to build intelisense-like, type-ahead, Google Suggest type functionality before.  It is hard.  I don’t fault LINQPad for not having it – especially in a free product, but I find myself typing Linq to Sql easier in Visual Studio and then copy/paste it into LINQPad – just to get (as Rob Bagby puts it) “the intelisense love”.  And if I’m already in Visual Studio, and don’t need the bells-n-whistles, I’ll just step into the debugger and use the Linq to Sql Query Analyzer.  (Perhaps a mashup product where I can use a VS debugger visualizer to alter the linq query in place the way I can alter variables’s values during debugging?  Or embed LINQPad in a window in VS so intelisense hooks and the strongly typed data context for my project are available?)

– No renamed columns and tables – For example, when I built my .dbml file, I spent some time cleaning up where the dba of yesteryear got “creative”.  The object name is “student” where the table is “people_who_go_here”, the object’s property name is “PropertyId” where the table’s column name is “ID”.  When I do a query in LINQPad, I have to use the old name.  I’ve been splunking through the Advanced Properties in the Query menu, and it looks like there’s a way to reference the .dll my .dbml file is in, and with that, I could perhaps run my new names through LINQPad, but I haven’t figured out how to use it yet, and there’s no help file.

Summary:

For what it does, it does very well – a “Linq Query Analyzer”.  I think the documentation could be a bit better – especially in the Advanced Properties windows, but the author has done wonders to make the interface intuitive so documentation isn’t necessary.  I’d love intelisense in here, though I know how hard that would be to pull off (and Query Analyzer doesn’t have it either without Red Gate).  The interface is gorgeous, intuitive, clean, and feature rich.  Reflecting into both a database, linq code, and pulling off results in a very performant way is just phenomenal – wish I knew how he did that.  Hats off to Joseph Albahari for a great product.