Create LINQ Expressions with LINQPaD

I found LINQPad a very useful tool to create and test LINQ queries outside visual studio.   LINQPad is also a great way to learn LINQ. It supports LINQ to objects,

LINQ to Sql, LINQ to Entities etc. It shows the lambda expression view and SQL view for your queries written in query comprehension syntax.

You can connect LINQPAD to Sql server/SQL CE  databases and start developing quarries using LINQ expressions without having to create any Data Contexts.

I’ve connected LINQPAD to AdventureWorks database which contains following sub schema.

image

Once connected to the database you can start developing LINQ to SQL queries. I am fetching a product with its higher rating reviews as a hierarchical projection using C# query comprehension expression syntax.

clip_image001

Once the query is executed the results tab displays the results as a hierarchical graph as shown below.

image

The Lambda Expression tab shows how the compiler converted our queary to Lambda expression.

image

Also the SQL tab shows the generated SQL statement by the LINQ query.

In addition to C# expressions you can also develop C# statements and display output at any stage using Dump() extension method provided.  The following C# Statement fetch all document information for a given product. Note that the Dump method display the result set graphically which makes it so much easier to develop/debug LINQ quarries.

clip_image001[9]

LINQPaD run as a standalone exe and no installation is required. It runs on .NET 3.5. Hope this helps.



Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s