Linqer is a tool that I have tested in the previous two weeks and I see it works pretty good. Even I’m not using it yet to convert SQL to LINQ code because I did it manually before I discovered that Linqer could have really helped me, I would recommend it for those who are just starting with LINQ and have knowledge of writing SQL queries.
Let’s pass through several steps so that I will help you get started faster…
2. Once you download the zip file, extract it and launch the Linqer4Inst.exe then add install location. In the location you will add, the Linqer.exe will be created.
3. Launch the Linqer.exe. Once you run it for first time, the Linqer Connection Pool will be displayed so that you can create connection to your existing Model
Click the Add button
Right after this, the following window will appear
#1 – The name of the connection string you are creating
#2 – Click “…” to construct your connection string using Wizard window
#3 – Chose your language, either C# or VB
#4 – Model LINQ to SQL or LINQ to Entities
Right after you select LINQ to SQL, the options to select the files for the Model will be displayed. In our case I will select LINQ to SQL, and here is the current progress
So, you can select existing model from your application or you can Generate LINQ to SQL Files so that the *.dbml and *.designer.cs will be automatically filled
#5 – At the end, you can chose your context name of the model which will be used when generating the LINQ code
Once you are done, click OK.
You will get back to the parent window filled with all needed info
and click Close.
Note: You can later add additional connections in your Linqer Connections Pool from Tools –> Linqer Connections
In the root folder where your Linqer.exe is placed, now you have Linqer.ini file containing the Connection string settings.
Ok, now lets go to the interesting part.
Lets create one (first) simple SQL query and try to translate it to LINQ statement.
If we add this query to Linqer, here is the result:
So, the LINQ code is similar to the SQL code and is easy to read since it’s simple. Also, if you notice, the tool generates class (you can add class name) with prepared code for using in your project. Perfect!
Now, lets try to translate a query with two joined tables (little bit more complex):
The LINQ generated code is:
So, if you can notice the where clause, we said in the SQL query: ... like "%a" and the corresponding LINQ code in C# is ... EndsWith("a"); - Excellent!
And the Class automatically generated by the tool is
Great! We have ready-to-use class for our application and we don't need to type all this code.
Besides this way to generate code, you can in same time use this tool to see the db results
I like this tool because mainly it’s very easy to use, lightweight and does the job pretty straight forward.
You can try the tool and send me feedback using the comments in this blog post.
I hope you will like it.