Intellisense support making it easier and faster to construct your queries,

Compile time checking,

Learning to write LINQ queries/lambdas is a must learn for .NET developers,

The benefits are clear, however there is a caveat when using LINQ. It is not possible to use Edit and Continue and with even the smallest change you need to restart your debugging session. As a result your development speed is decreased dramatically.

The solution as always is to use the right tool and in this case the right tool is LINQPad. It provides a flexible UI allowing you to use LINQ in various ways.

In our latest version our team released an XPO context driver for LINQPad. Let’s see how to configure it.

Firstly we need to install the driver found at C:\DevExpress 2011.2\Components\Tools\DXperience\XPOContextDriver.lpx.

Secondly we need to setup a new connection.

In this example we are going to use the MainDemo assembly containing the business objects.

LINQPad populated the domain in a hierarchical treelist. This allows us to enjoy using drag & drop plus intellisence in its expression editor to form the LINQ queries. Furthermore it is possible to use your style of language as demonstrated below.

The cool part is that LINQPad, written by the great Joe Albahari, is available for free. It is strongly recommended as a great way to learn LINQ.

Now for the fun part, let’s see it in action. Imagine we have the following code in our VS.

var queryable = from c in contacts

let tasks = c.Tasks.Where(t => t.ActualWork < 0)

where tasks.Any()

orderby c.LastName

selectnew {

c.LastName,

Orders = tasks.Count(),

};

We wish to see the results of queryable variable ,the best way to achieve this is to set a breakpoint then hit F5. Next we wait for our app to load and navigate to the action that will hit the breakpoint. Finally we must select the queryable variable and hit Shift+F9 to invoke the debugger window and examine the result set. Now we can try to make our requirements more complex. Lets say we also want to examine the result set when ActualWork>10. The solution is really easy when using LINQPad, we simply need to copy paste the code from VS to LINQPad the expression editor like this,

After this we can quickly and easily form queries as we wish and examine their result sets instantly. Using the excellent and cheap LINQPad Autocompletion it is possible to use VS like intelligence to further speed up your development.

PS: eXpandFrameWork contributors are already using the Autocompletion feature since LINQPad offered a license for its contributors.

We would appreciate your feedback on this post. Has it been useful to you? Feel free to contact us with any further questions