One of the tools I find myself using quite a lot recently is LINQPad. In my new project we are using NHibernate, which together with the Linq provider is a real joy. I can still remember when I was using NHibernate for the first time in a project and to be honest, the Criteria API to write queries is just not nice. As soon as it comes to more complex search queries or the dynamic combination and aggregation of criterias (e.g from a search forms) it can get quite confusing. Or let me say it in a different way: In the end, the criteria API works absolutley fine and you can write all the queries you want, simple and complex ones, the only problemI always had was, that it just didn’t feel natural.
One important point of using an ORM for me is, to get me away from my stored procedures and sql code and create a certain level of abstraction. HQL or the criteria API always felt like something betwixt. We are using the repository pattern which implements IQueryable<T> and thus querying against our repository feels natural and integrates really nice. Nonetheless I had a query today where I had to use HQL rather than Linq, simply because I couldn’t figure out a nice and fast way how to write the query using Linq.
Anyway, back to LINQPad. Don’t know what LINQPad is? Here is what they say on their website:
LINQPad lets you interactively query SQL databases in a modern query language: LINQ. Kiss goodbye to SQL Management Studio!
LINQPad supports everything in C# 3.0 and Framework 3.5:
LINQ to Objects
LINQ to SQL
LINQ to XML
(Even old-fashioned SQL!)
Sadly, in order to get IntelliSense support, you have to pay something (ok, not a lot, but….). But the best thing about LINQPad for me is the “Samples” section. Packed with 200+ examples from the book C# in a Nutshell. I find myself looking up examples more often than actually using the tool itself.
You will find far more complex examples than the usual “get me all orders where the date is in the past” and especially the examples with lambda expressions are very helpful. Although my head still hurts after to much lambda quatsch today….