The Visual Linq query builder is a Visual Studio 2008 addin. It's a designer that helps you create Linq to Sql queries in your application. Both C# and VB projects are supported.

As you will read it in this post, this project developed by interns is a prototype for a new kind of designers.

Please give us your feedbacks !!!

Project history

It is an academic project developed during a Microsoft France internship in collaboration with Microsoft Corporation.I have been the 'local' manager and technical lead of the project. I wanted to create a VS designer using WPF for a long time and I had the idea of a query builder for Linq to Sql. Then came the opportunity to organize a 6 months long internship in collaboration with Ms Corp.

I have recruited two french students that I want to thank again today for their excellent job.

- Simon Ferquel from SupInfo who is now working in a french company (Winwise). You may know him from the time he was student as the author of a funny tool for Vista : myExposé.

- Johanna Piou from ISEN Toulon who is still student this year and who is well known for her brilliant Imagine Cup participation in the Interface Design category.

Linq to Sql and Linq more generally speaking, is a new technology mainly based on language evolutions. As any new syntax, you have to take some time to get familiar with it.

The VLinq project as any designer helps you to build graphically Linq to Sql queries but we wanted to keep it visually very close from the code. The goal is not to hide the generated code but to make it visible in the designer. It's a kind of mix between a classical designer and a graphical intellisense.

VLinq also helps you grouping all queries at the same place allowing easy management (edit, add, remove) and previewing and testing.

Last goal: releasing the whole solution, including source code to share with you our experience about using WPF with VS2008 extensibility.

What do we release ?

The whole project has been developed using Visual Studio 2008 (betas then RTM) and Expression Blend. We provide the whole solution (binaries + source code). The solution contains a Setup project for a quick installation (msi file).

Once Visual Linq Query Builder is installed, you can create a new project or open an existing project (C# or VB.Net). From this designer you will be able to create, modify and delete queries. When editing a query, the query designer will appear and let you build your query visually. At each time the designer is saved, the corresponding code (C# or VB.Net) will be generated. Then the queries are ready to be used by your project. The following steps are for the first time users of Visual Linq Query Builder.

- Create a new project

If you installed Visual LINQ Query Builder, you can create a new project or open an existing project (C# or VB) in Visual Studio.

- Add a LINQ to SQL class

Once a project is created, a LINQ to SQL class should be added to the project.

- Add connection to SQL database

If Linq to SQL class is added, a .dbml file is added to the project. You open the .dbml and can set the connection to SQL database by clicking “Server Explorer” and “Add Connection”

To work with LINQ to SQL and Visual LINQ Query Builder in Visual Studio 2008, you will need a database that you can query. If you already had a database, you can set the connection to the database by clicking “Server Explorer”.

Otherwise, you can access the copy of the Northwind database that accompanies the C# samples that ship with Visual Studio 2008. You can also download the latest C# samples from http://msdn2.microsoft.com/en-us/bb330936.aspx. The Northwind.mdf will be found in the directory, CSharpSamples\LinqSamples\Data.

You can set the connection to the copy of Northwind.mdf or your database.

Once connection is added, you can navigate to the objects in the database and select a table you want to query.

- Add the designer to the project

Add a new item, “VLinq queries” to the project. When opening the new .vlinq file added to your project, the query bag designer will appear.

- Set the connection to VLINQ

In the Properties of the vlinq, set Connection String to the database you want to query. Select “Visual studio Connection” and the database.

- Create a new query

If you open the .vlinq file added to the project, you can see query bag designer. In the query bag designer, you can create a query using the query bag designer by clicking an icon “Create a new query”.

- Edit the query in the query bag designer

- Query in collapsed mode

- Preview the query result

Once you edit the query and “save” the .vlinq file, the code is generated. If you click “Preview”, you can see the query result in the below.

- View the generated code

Query designer code is generated if you save the query. You can build the project using the code.