Linqpad

Anyone who is familiar with C# and .NET will surely know what LINQ is. But not many developers are aware of LinqPad. LinqPad is a cool, useful and highly powerful tool to write and execute LINQ queries. It was developed by Jospeh Albahari. Joseph and Ben Albahari are the famous brothers who wrote the C# in a Nutshell and other popular C# books for Oreilly. They are well-experienced in enterprise development with .NET

Linqpad allows you to query against various data sources including collections, arrays, SQL Server and Oracle databases. It also includes tonnes of sample examples, a sample database and over 200 examples from the book "C# 4.0 in a Nutshell".

If you are a .NET developer and use LINQ frequently, then this tool would be really handy for you. I found it very useful when trying to solve problems that involved query operators and query expressions. Just looking at the sample examples helped me learn a lot.

Take for instance this query included in LinqPad:

var names = new[] { "Tom", "Dick", "Harry", "Mary", "Jay" }.AsQueryable();

var query =

     from n in names

     where n.Length > 3

     let u = n.ToUpper()

     where u.EndsWith ("Y")

     select u;

    

query.Dump();

 

It does not even use a database! It illustrates the use of multiple WHERE clauses. The output is

HARRY

MARY

Consider this sample query included in LinqPad:

var names = new[] { "Tom", "Dick", "Harry", "Mary", "Jay" }.AsQueryable();

(

     from n in names

     let vowelless = n.Replace ("a", "").Replace ("e", "").Replace ("i", "").Replace ("o", "").Replace ("u", "")

     where vowelless.Length > 2

     orderby vowelless

     select n               // Thanks to let, n is still in scope.

)

.Dump();

 

It demonstrates use of "let". The output is

Dick

 Harry

 Mary

 Many more such examples are included in LinqPad. You can view the sample query and right away execute it by clicking the Execute button.

linq.jpg

LinqPad is available for free download at:

http://www.linqpad.net/