Welcome to MSDN Blogs Sign in | Join | Help

Mitsu's blog

Discussing topics related to .Net, WPF, C# and Linq
Visual Linq query builder for Linq to Sql: VLinq

Hi all,

After almost one year of work and organization, I am very happy to share this project with you:

http://code.msdn.microsoft.com/vlinq - new setup fixed (4/17/2008)

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.

clip_image016

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.

You can find the French description of the project here: http://msdn.microsoft.com/fr-fr/vcsharp/default.aspx (coming soon).

The project goal

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).

You can get all the stuff here: http://code.msdn.microsoft.com/vlinq/ under the 'Releases' tab. (msi, quick reference guide, user documentation, webcast).

---------------------------------------------------------------------------------------------------------------------------------

Quick Reference Guide

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.

clip_image002

- Add a LINQ to SQL class

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

clip_image004

- 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”

clip_image006

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.

The setup guideline for the SQL database can also be found in Charlie Carvert’s bolg.

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

clip_image008

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.

clip_image010
- 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.

clip_image012

- 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”.

clip_image014

- Edit the query in the query bag designer

clip_image016

- Query in collapsed mode
clip_image018

- 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.

clip_image020

- View the generated code

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

clip_image022

Have Fun !

Mitsuru FURUTA - Microsoft France

Posted: Wednesday, April 02, 2008 11:29 AM by mitsu

Comments

Dariusz quatscht said:

Letztes Jahr konnte ich bereits einen frühen Prototypen von VLINQ sehen. VLINQ ist ein Addon für

# April 2, 2008 10:14 AM

gduncan411 said:

This looks like a VERY cool project! Thanks for releasing it...

I grabbed the MSI, installed it (on Vista), but don't see the solution/source. The C:\Program Files\Microsoft VLinq Query Builder\ folder only has the bin's, ico, etc

Is the MSI only bin's or does it also contain the source?

Thanks,

Greg

# April 2, 2008 4:20 PM

denny said:

I tried to sign in on the code-website but that does not seem to work.

installed on VS 2008 Pro RTM on Vista Ultimate x86.

not working, no designer icon in vs items.

something in setup is not working.

the files are there ... looks like VS has the stuff.

perhaps we need to run devenv with a packages command ??

# April 2, 2008 6:17 PM

mitsu said:

Very strange. Can you check the file 'VLinq queries.zip' is in \Program Files\Microsoft Visual Studio 9.0\Common7\IDE\ItemTemplates\CSharp\1033

If so, close all VS instance and try 'devenv /installvstemplates'

# April 2, 2008 7:21 PM

mitsu said:

Thanks to Denny, please try to run the setup 'as admin' if your under Vista.

# April 3, 2008 4:06 PM

VinceX.NET said:

Salut Mitsu, super l'article...

J'ai 1 souci avec mon VS.NET 2008 prof.;

je vois pas "LINQ to SQL" dans Add Item...

Tu sais comment fixer ça ?

merci

-Vince

# April 4, 2008 6:42 AM

mitsu said:

Hello VinceX.NET,

Did you try to run the setup as admin ?

If you have both VS2005 and VS2008 installed, then after installation, run the VS2008 command line and enter "devenv.exe /installvstemplates".

# April 4, 2008 9:45 AM

CompuBoy said:

Hi Mitsu!

Thanks! Seems to be a great tool!

I've tried installing it on 'VS.NET Team Suite 2008 RTM' without success. The installation ends successfully but "VLinq Query" item is not addded to the item list. Following your guides, I checked "\Program Files\Microsoft Visual Studio 9.0\Common7\IDE\ItemTemplates\CSharp\1033". It didn't contain the 'VLinq queries.zip' file so I added it from the sources by hand and ran 'devenv /installvstemplates'. This time 'VLinq query' was shown in the items list but when I try to invoke the designer of my VLinq query, I get the error 'cannot locate resource 'querybagdesigner.xaml'.

My Windows is XP SP2.

Any ideas what the problem is?

# April 7, 2008 9:36 AM

CompuBoy said:

Hi Mitsu!

Thanks! Seems to be a great tool!

I've tried installing it on 'VS.NET Team Suite 2008 RTM' without success. The installation ends successfully but "VLinq Query" item is not addded to the item list. Following your guides, I checked "\Program Files\Microsoft Visual Studio 9.0\Common7\IDE\ItemTemplates\CSharp\1033". It didn't contain the 'VLinq queries.zip' file so I added it from the sources by hand and ran 'devenv /installvstemplates'. This time 'VLinq query' was shown in the items list but when I try to invoke the designer of my VLinq query, I get the error 'cannot locate resource 'querybagdesigner.xaml'.

My Windows is XP SP2.

Any ideas what the problem is?

# April 7, 2008 9:36 AM

mitsu said:

Hi,

It seems that you are not on a english system.

Next release will be localized.

# April 7, 2008 1:05 PM

CompuBoy said:

No! I am using the English version of Windows XP. I've just noticed one problem. My Visual Studio is installed on 'D:\Program Files\Microsoft Visual Studio v9.0' but the item templates copied by the installer is put on 'C:\Program Files\Microsoft Visual Studio v9.0'. I've put them in the correct path manually but still the same problem with finding 'querybagdesigner.xaml'.

# April 8, 2008 5:01 AM

CompuBoy said:

No! I am using the English version of Windows XP. I've just noticed one problem. My Visual Studio is installed on 'D:\Program Files\Microsoft Visual Studio v9.0' but the item templates copied by the installer is put on 'C:\Program Files\Microsoft Visual Studio v9.0'. I've put them in the correct path manually but still the same problem with finding 'querybagdesigner.xaml'.

# April 8, 2008 5:01 AM

David Hayden - Florida .NET Developer - C# and SQL Server said:

The Visual LINQ Query Builder is a Visual Studio 2008 Add-In and designer that helps you create LINQ to SQL Queries in your application.

# April 8, 2008 9:35 AM

David Hayden - Florida .NET Developer - C# and SQL Server said:

The Visual LINQ Query Builder is a Visual Studio 2008 Add-In and designer that helps you create LINQ to SQL Queries in your application.

# April 8, 2008 9:36 AM

Jeff Gonzalez said:

Great!  Big help - I've been teaching Linq and I think this will really help - especially with the joins.

Thank you!

# April 9, 2008 10:36 PM

Hock Blogs .NET said:

Visual LINQ Query Builder add-in looks very cool

# April 10, 2008 3:02 AM

ASPInsiders said:

My source code reading didn't have any rhyme or reason to it this week, but most of them were large,

# April 10, 2008 3:27 AM

Paul Mooney said:

Visual Linq query builder for Linq to Sql: VLinqThe Visual Linq query builder is a Visual Studio 2008...

# April 10, 2008 6:57 AM

Ryan C Smith said:

Hi Hi!

Installed on Vista x86 Visual Studio Team System 2008...the install completed fine, and I see the item templates...but after selecting Add->Vlinq Queries, I get the following error: Custom tool error: Unable to initialize the Query Formatter File Queries2.vlinq Line:1 Column: 1

Cheers!

# April 10, 2008 5:44 PM

Jim R said:

Sorry, it was a nice concept, but it just doesn't work.

Judging by all the problems everyone is having, the installation obviously wasn't tested on Vista. I suggest you test it on several Vista machines and release a version that works. And the devenv /installallvstemplates hack? It removes all my templates! Yes, I ran it all 'as Administrator'.

# April 11, 2008 3:55 AM

Mitsu said:

Hi, we will fix those issues quickly.

Please understand this project is not our daily work.

Sorry again for these troubles.

# April 11, 2008 4:54 PM

Blog del CIIN said:

Si hace unos meses hablábamos de una útil e imprescindible herramienta para probar nuestras consultas

# April 13, 2008 5:46 PM

Mike said:

Looks pretty amazing, I love the visualization of the collapsed query, it's not often a UI designer can create exactly what a developer wants, but this looks like it.

I'll try it just because it looks so cool!

# April 16, 2008 5:31 PM

asiaenforcer said:

Looking forward to test the VLINQ

# April 17, 2008 9:51 PM

mitsu said:

The installation has been patched. Thanks for your patience and sorry again for the first setup version.

You can still continue to post your comments here and tell if you meet some issues.

# April 17, 2008 10:53 PM

msdn Austria said:

Französische Studenten haben als Internship in Redmond ein Visual Studio 2008 Add-In zur visuellen Erstellung

# April 18, 2008 7:41 AM

Dave Ryan said:

If says 'Connection failed' however I have selected a valid connection from the data connnections within Server Explorer. In fact I can open all tables etc. from the data connections windows.

# April 18, 2008 5:51 PM

Dave Ryan said:

It continously asked for recompilation when it has already been compiled.

# April 18, 2008 5:55 PM

mitsu said:

@Dave: sounds strange. When in the property editor, make sure you have checked the radiobox correctly in addition to providing the connnection string.

Yes, recompilation is asked many times. We are using the project compiled information to run the query which is a strange choice but which allows to execute the query in a very close environment that what the user will have at runtime. This part has to be optimized because we ask for recompilation at each time the document is modified (even if it does not generates new code). I hope to solve this point in the next release.

# April 19, 2008 1:09 PM

Jay said:

I'm trying to do a join between 2 entities. One is a Group table and one is a Status table. The primary key on the Status table is StatusId. There is a foreign key on the Group table for StatusId. They are both GUIDs

When I try to use the tool to do a join I get this error: "The Property "StatusId" type is not valid in a join declaration". I know I could just reference Status from within the Group table but I'm just trying to see if the join functionality works.

# April 21, 2008 7:15 PM

Charlie Calvert's Community Blog said:

Welcome to the forty-third issue of Community Convergence. The last few weeks have been consumed by the

# April 23, 2008 4:58 PM

Hot Topics said:

Thanks to Roger Jennings for highlighting the Visual LINQ Query Builder project that is now on MSDN Code

# April 26, 2008 2:03 PM

Seth said:

I'm having the same problem that Jay is having.  All of our keys are GUIDs, and this tool is telling me that "The property <guidcolumnhere> is not valid in a join declaraion".  Great looking tool, just not usable if you're using GUIDs.

# April 29, 2008 9:44 AM

Around and About .NET World said:

Un editor visuale per LINQ-to-SQL

# May 5, 2008 5:15 AM

IDEA software said:

Sul Mitsu's blog viene presentato VLINQ, ovvero E' un add-in per Visual Studio 2008 che consente di creare query per LINQ-to-SQL in modo visuale. Allo stesso indirizzo &egrave; disponibile anche un breve tutorial. VLINQ &egrave; ospitato su MSDN Code

# May 6, 2008 11:12 AM

Jon Galloway said:

h2.entry-title {font-size: 1.1em; clear:left;} ul.hfeed {list-style-type: none;} li.xfolkentry {clear

# May 8, 2008 5:15 AM

Ali Muslim said:

thank you for the tool.

it provides good help with easiness.

# May 9, 2008 6:48 AM

江南白衣 said:

Visual LINQ Query Builder is an add-in to Visual Studio 2008 Designer that helps you visually build LINQ to SQL queries. Functionally it provides the same experience as, for instance the Microsoft Access Query Builder, but in the LINQ domain. The entire

# May 11, 2008 11:59 AM

nealb said:

Nice effort, however the tool is extremely confusing! I wasn't able to create a single query, because the tool is not intuitive at-all.  The article was my only hope and it leaves-out far too many details during the walk-through.  For example: I have no idea how the author proceeded from a "New (blank) Query" to this screen, showing a datasource: http://blogs.msdn.com/blogfiles/mitsu/WindowsLiveWriter/VisualLinqquerybuilderforLinqtoSqlVLinq_A02A/clip_image016_2.jpg

When I tried to add a datasource, all I saw was a blank dialog with no obvious purpose.

The flashing and zooming graphics are neat, but the tool is buried so far down in the IDE and it is too hard to find and the tools' UI is far too vague.

Nice initial effort, but this thing needs a lot more work before I can recommend it to my team. I hate to be the dissenter here, but someone had to say it.

Thanks anyway

# May 12, 2008 11:39 AM

mitsu said:

Hi nealb,

Even if many people found it easy to use, I take your point. The best I can recommand is to look at the webcast (see link on the project page).

Just to remind, this is a free tool developed by interns. One of the goals was to test what kind of new UI we could make for a visual studio addin using WPF. It's maybe not intuitive for everyone but I think it's an interesting try. We will fix some issues but we did not plan to 'work' again on this project. It's free, the source code is provided and I think it's already a good thing !

# May 12, 2008 7:22 PM

ScottGu's Blog said:

Apologies for the sparseness of my posting the last few weeks - work and life have been busy here lately

# May 21, 2008 1:03 AM

BusinessRx Reading List said:

Apologies for the sparseness of my posting the last few weeks - work and life have been busy here lately.&#160;

# May 21, 2008 1:35 AM

Mirrored Blogs said:

Apologies for the sparseness of my posting the last few weeks - work and life have been busy here lately

# May 21, 2008 1:49 AM

Shimmy said:

null refference exception is thrown at having section when I click the textboxes (< edit >).

# May 21, 2008 6:46 AM

Shimmy said:

null refference exception is thrown at having section when I click the textboxes (< edit >).

# May 21, 2008 6:48 AM

Mike said:

"We will fix some issues but we did not plan to 'work' again on this project. It's free, the source code is provided and I think it's already a good thing !"

Move it to Codeplex! Others will work on it for sure.

# May 21, 2008 7:13 AM

adefwebserver said:

I had problems on my 64bit XP. Install works but templates don't show up. BUT geez people it's free and it works in some situations. Just say It didn't work for me and move on. Don't slam them because it did not work for you. Well I will try it on my computer at home...

# May 21, 2008 12:38 PM

adefwebserver said:

Correction! I was trying to get it to work in a Web Site project and the directions clearly indicate that it works with a Web Application Project. It works great! Wonderful work. Thank you so Much!

# May 21, 2008 12:51 PM

Joycode@Ab110.com said:

【原文地址】 May 20th Links: ASP.NET, ASP.NET AJAX, .NET, Visual Studio, Silverlight, WPF 【原文发表日期】 Tuesday

# May 22, 2008 6:19 PM

Scott Guthrie's Blog in Dutch said:

Mijn verontschuldigingen voor de weinige posts de laatste weken. Mijn werk en leven zijn enorm de druk

# May 24, 2008 3:34 AM

jayesh said:

nice work

really relly good

and lost of time saving

# May 24, 2008 9:47 AM

Topper said:

Bonjour Mitsu

Plus haut une autre personne parle d'un "connection failed" quand il essaye de tester la requete.

J'ai le meme probleme et ma connection string est bien definie dans les proprietes.

Je peux acceder par le server explorer a mes bases avec la meme connection string donc je ne comprend pas pourquoi VLINQ ne pourrai pas.

merci de l'aide que vous pourriez apporte

# May 28, 2008 6:22 AM

Scott Guthrie's Blog in French said:

Mes excuses pour le peu de publications au cours des dernières semaines – le travail et la vie en générale

# June 3, 2008 12:40 AM

Julio Cesar Ortega said:

No he podido, probarlo en mi vs2008, me sigue mandando este error "No se puede localizar el recurso querybagdesigner.xaml", alguna sugerencia de como arreglarlo?

Tengo Vista Bussines en Español y VS2008 Professional en Español.

Espero su ayuda....

# June 7, 2008 7:19 PM

Gary Hoffer said:

Problems I encountered:

1 I could not get it to generate more than one query in the code. Query bag shows 2 but only one is generated.

2. When I press the Preview button, It displays "No Data. If your query..." (sorry, I couldn't cut and paste)

3. When I first create a query it adds my namespace to the Type when generating the code as in:

from b in context.GetTable<Namespace.Brand>()

when I manually remove the namespace. it compiles correctly.

# June 14, 2008 8:59 PM

Tom said:

Hi,

It would be really useful to work against different DataContext such as the Entitiy Framework and frameworks such as ADO.Net Data Services .

Tom

# June 16, 2008 2:48 PM

Chakrapani said:

It appears this VLinq query builder installer (vlinq.msi) works only on VS 2008 eds., Standard or above, but not on Express Eds., as I tried on both versions. Am I correct?

# June 28, 2008 8:33 PM

Chakrapani said:

It appears this VLinq query builder installer (vlinq.msi) works only on VS 2008 eds., Standard or above, but not on Express Eds., as I tried on both versions. Am I correct?

# June 28, 2008 8:33 PM

acangialosi said:

Very cool extension.  Have you considered adding this to the Visual Studio Gallery?

# July 31, 2008 2:42 PM

John W said:

This tool has worked as advertised for me...very cool and helpful for this novice.  If anyone knows how to tell it to take the first row in a return set, I would greatly appreciate the knowledge transfer.  Specifically, I'm trying to sort by a column in desc order, then take the top row (i.e. the last row added).

Thanks.

# August 17, 2008 7:58 PM

R.Kaiser said:

Even with the "fixed" setup it is not possible to install it because it does not find "VLinq queries.zip"

Any hints?

# August 24, 2008 12:15 PM

bob said:

i just gave up because of the installation issues on vista. nice idea but needs a lot of improvement - why, but why do you need a accordian type functionality??

why cant this be simple?

# August 25, 2008 1:35 PM

ricky said:

When I run the query, I get an error message popup box that is a window title "Preview Unavailable".  The contents of the window reads "Connection failed" with an OK button.

I have selected the database connection and I can freely explore the database from the object explorer as well as in the query designer, I just can't connect for some reason?

# September 2, 2008 8:11 PM

John Baughman said:

For the "recompile" messages, make sure you don't have the *.designer.cs file open. This can prevent it from being regenerated.

Great tool for a first round version! Thanks!

# September 4, 2008 11:28 AM

Gerlei Márton blogja az Architektúra Fórumon said:

Van egy ilyen kis LINQ Query szerkesztő: Visual Linq query builder for Linq to Sql: VLinq Ami &quot;poén&quot;

# September 5, 2008 8:52 AM

yodelmis said:

tengo el mismo problema de Julio Cesar Ortega

es decir mis windows (xp sp3 y vista) y mi vs2008 sp1 estan en spanish.

Ya pude instalarlo, pero cuando intento utilizarlo, me da el error de no encontrar el recurso.

# September 6, 2008 4:23 PM

Shailesh said:

Its work fine when I need data from Data base but how i do same for  insert update,delete

if possible please let me know

mails.shailesh@gmail.com

# September 24, 2008 4:15 AM

mitsu said:

insert, update and delete actions are automatically generated by Linq to Sql. You just have to call context.SubmitChanges()

# September 25, 2008 7:12 AM

sam2008 said:

LINQ defines a set of query operators that can be used to query, project and filter data in arrays, enumerable classes, XML, relational database, and third party data sources. While it allows any data source to be queried, it requires that the data be encapsulated as objects. So, if the data source does not natively store data as objects, the data must be mapped to the object domain. Queries written using the query operators are executed either by the LINQ query processing engine or, via an extension mechanism, handed over to LINQ providers which either implement a separate query processing engine or translate to a different format to be executed on a separate data store (such as on a database server as SQL queries). The results of a query are returned as a collection of in-memory objects that can be enumerated.

=================================================

Sam

<a href="http://www.widecircles.com">Link Building</a>

# October 20, 2008 1:52 AM

mars said:

 allways got zhe error1001:can't find the path D:\Program Files\Microsoft Visual Studio 9.0\Common7\IDE\ItemTemplates\CSharp\Data\1033\VLinq queries.zip

can you tell me how can I setup the VLinq buildder?

my Email: mars8466@163.com  

thanks!

# November 10, 2008 9:13 PM

jay_atwork said:

Great product.  But I will be damned if I can get it to work. No matter what config I try I get a connection failed error.  I have a server explorer connection created, and I am able to open and edit items via that.  I have also coded a simple query based off the datacontext and that works fine.  I have tried to use the VS connections and the custom connections.  Neither of these work.  

# November 11, 2008 11:15 AM

Amir Simantov said:

I have tried it all - radio buttons, exact connection string entered manuall... does not work.

# November 12, 2008 7:12 AM

Jose said:

When I try to use any operator other than the == against an integer or a decimal; it breaks. For example v.Cost > 1000 it tries to run then it says "String must be exactly one character long". It is not even a string, it is an integer or decimal.

# February 5, 2009 4:28 PM

seek said:

but it can't support other language vs2008...

# February 13, 2009 9:05 PM
Leave a Comment

(required) 

(required) 

(optional)

(required) 

Comment Notification

If you would like to receive an email when updates are made to this post, please register here

Subscribe to this post's comments using RSS

Page view tracker