Templates | Linqer


Templates are a powerful feature of Linqer 4.6.
Using a combination of the model tree view and templates, you can automate the code generation process for your Visual Studio projects. Whenever you use LINQ, you have to write many lines of code manually to handle repeated operations. Although Visual Studio Intellisense helps, you still have to type a lot.
Using the LinqerTemplate library, you can teach Linqer how to produce special code for your project. Linqer can automatically produce two class declarations. The first class consists of all fields returned by your LINQ expression. The second class is a list of the elements in your first class. The contents of this list are generated based on data from each original LINQ expression.
Linqer produces similar classes based on a built-in "General List" template. The code of this template can be modified using either C# or VB. You can create many other templates right in Linqer or in Visual Studio using LinqerTemplate.dll.
Templates are processed by Linqer during the conversion process. As soon as conversion is complete, you can find the produced code under the Templates tab at the bottom of the screen.
Model tree view can speed up template processing. For example, if you standardized CRUD operations for your MVC project, you know that each entity in your schema must have 4 methods of supporting CRUD operations. You can create 4 templates for each operation (Create, Read, Update, and Delete). Now, you can drag an entity from the model tree view and drop it into the LINQ window. This drag-and-drop operation converts the SELECT * FROM "yourtable" SQL statement to LINQ and processes your 4 CRUD templates at the same time. As a result, you receive code for the 4 methods for each selected entity. All you need to use is the “Copy to Clipboard” button; then, paste these templates one-by-one into your Visual Studio MVC controller.
If you have a pattern in your MVC JavaScripts, you can also use templates to produce JavaScript code for each entity of your model.
Thus, Linqer 4.6 is not just a SQL to LINQ converter, but a powerful tool for generating code for LINQ projects, which can saves days, weeks, and even months of development time.