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

Comments (81)

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

  2. gduncan411 says:

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

  3. denny says:

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

  4. mitsu says:

    Very strange. Can you check the file ‘VLinq queries.zip’ is in Program FilesMicrosoft Visual Studio 9.0Common7IDEItemTemplatesCSharp1033

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

  5. mitsu says:

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

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

  7. mitsu says:

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

  8. CompuBoy says:

    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 FilesMicrosoft Visual Studio 9.0Common7IDEItemTemplatesCSharp1033". 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?

  9. CompuBoy says:

    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 FilesMicrosoft Visual Studio 9.0Common7IDEItemTemplatesCSharp1033". 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?

  10. mitsu says:

    Hi,

    It seems that you are not on a english system.

    Next release will be localized.

  11. CompuBoy says:

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

  12. CompuBoy says:

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

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

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

  15. Jeff Gonzalez says:

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

    Thank you!

  16. Visual LINQ Query Builder add-in looks very cool

  17. ASPInsiders says:

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

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

  19. Ryan C Smith says:

    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!

  20. Jim R says:

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

  21. Mitsu says:

    Hi, we will fix those issues quickly.

    Please understand this project is not our daily work.

    Sorry again for these troubles.

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

  23. Mike says:

    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!

  24. asiaenforcer says:

    Looking forward to test the VLINQ

  25. mitsu says:

    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.

  26. msdn Austria says:

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

  27. Dave Ryan says:

    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.

  28. Dave Ryan says:

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

  29. mitsu says:

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

  30. Jay says:

    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.

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

  32. Hot Topics says:

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

  33. Seth says:

    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.

  34. Un editor visuale per LINQ-to-SQL

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

  36. Jon Galloway says:

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

  37. Ali Muslim says:

    thank you for the tool.

    it provides good help with easiness.

  38. 江南白衣 says:

    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

  39. nealb says:

    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

  40. mitsu says:

    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 !

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

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

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

  44. Shimmy says:

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

  45. Shimmy says:

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

  46. Mike says:

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

  47. adefwebserver says:

    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…

  48. adefwebserver says:

    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!

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

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

  51. jayesh says:

    nice work

    really relly good

    and lost of time saving

  52. Topper says:

    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

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

  54. Julio Cesar Ortega says:

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

  55. Gary Hoffer says:

    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.

  56. Tom says:

    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

  57. Chakrapani says:

    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?

  58. Chakrapani says:

    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?

  59. acangialosi says:

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

  60. John W says:

    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.

  61. R.Kaiser says:

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

    Any hints?

  62. bob says:

    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?

  63. ricky says:

    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?

  64. John Baughman says:

    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!

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

  66. yodelmis says:

    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.

  67. Shailesh says:

    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

  68. mitsu says:

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

  69. sam2008 says:

    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>

  70. mars says:

     allways got zhe error1001:can’t find the path D:Program FilesMicrosoft Visual Studio 9.0Common7IDEItemTemplatesCSharpData1033VLinq queries.zip

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

    my Email: mars8466@163.com  

    thanks!

  71. jay_atwork says:

    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.  

  72. Amir Simantov says:

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

  73. Jose says:

    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.

  74. seek says:

    but it can’t support other language vs2008…

  75. VexinSoft says:

    Hello,

    I give up,…

    After many try, it’s impossible to make it run on vista and VS2008.

    I have try all the proposed solution by Mitsu above, but…

    I will take time to create my query wihtout this wonderful tool.

    Gilles

  76. Will says:

    Hello,

    This tool looks really good, however I am a little lost. I have read the posts here and many have helped (e.g. needing to run ‘devenv /installvstemplates’). However I am unable to figure out how to set the connection string.

    I would like to know if you can describe in more details how to get to this dialog: http://blogs.msdn.com/blogfiles/mitsu/WindowsLiveWriter/VisualLinqquerybuilderforLinqtoSqlVLinq_A02A/clip_image012_2.jpg

    The property window I see for the vlinq class does not have a connection string option. I have also noticed that the video shows a different version of vlinq. I was wondering if I have the wrong version. If so, can you provide a URL for the newest version?

    Thanks,

    Will

    – Will

  77. Anthony says:

    I have just stumbled upon this amazing tool and I have to say thank you it is really amazing what you have achieved, it is a real help.

    One thing I want to do and I do not know if it is supported is to get things make more complicated select citereon. For example I want to get a weighted average eg: sum(a*b)/sum(a) where a and b are some values in the table. I would do this with a lambda expression normally as say:

    Group.Sum(Function(f) f.a * f.b) / Group.Sum(Function(f) f.b)

    I cannot seem to do something like that in your tool but wondered if perhaps it was possible and I was just missing something simple?

    Thanks again for a great piece of work

  78. Michael Frentzen says:

    Good Software that assembly versions of speches

  79. Georg Gungl says:

    Hi,

    I have the same "missing querybagdesigner.xaml" problem with German VS2008 and latest VLinq (4/17/2008) version.

    May be a workaround or new version the next time?

    Thanks,

    Ciao:

    GG 😉

  80. Harald says:

    Hey

    Is there anything equal for VB.NET 2010!?

    THX