Create LINQ Expressions with LINQPaDPosted: December 30, 2009
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.
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.
Once the query is executed the results tab displays the results as a hierarchical graph as shown below.
The Lambda Expression tab shows how the compiler converted our queary to Lambda expression.
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.
LINQPaD run as a standalone exe and no installation is required. It runs on .NET 3.5. Hope this helps.