Templates | Linqer

Templates in Linqer

Templates are a robust feature within Linqer 4.6. By leveraging the model tree view and templates, you can streamline the code generation process for your Visual Studio projects. When working with LINQ, manual coding for repetitive tasks is often required. While Visual Studio Intellisense offers assistance, it still demands significant typing effort.

The LinqerTemplate library empowers you to instruct Linqer on producing customized code tailored to your project's needs. Linqer seamlessly generates two distinct class declarations. The initial class encompasses all fields yielded by your LINQ expression, while the subsequent class constitutes a list of elements derived from the first class. Each list item is meticulously crafted based on data extracted from the original LINQ expression.

Linqer also offers predefined classes generated through its built-in "General List" template. This template's code can be modified using either C# or VB. Furthermore, you have the flexibility to create numerous other templates directly within Linqer or within Visual Studio using the LinqerTemplate.dll.

During the conversion process, Linqer diligently processes templates. Once conversion concludes, you can locate the generated code under the Templates tab at the bottom of the screen.

The model tree view significantly expedites template processing. For instance, if you've standardized CRUD operations for your MVC project, where each entity necessitates four supporting CRUD methods, you can design four templates for each operation (Create, Read, Update, and Delete). By dragging and dropping an entity from the model tree view into the LINQ window, you seamlessly convert the SELECT * FROM "yourtable" SQL statement to LINQ, concurrently triggering the processing of your four CRUD templates. Consequently, you obtain code for the four methods pertaining to each selected entity. Simply utilize the "Copy to Clipboard" button and paste these templates individually into your Visual Studio MVC controller.

If your MVC JavaScripts adhere to a pattern, templates can also be employed to generate JavaScript code for each entity within your model.

Hence, Linqer 4.6 transcends its role as a mere SQL to LINQ converter, emerging as a potent tool for code generation in LINQ projects, promising substantial savings in development time, spanning days, weeks, and even months.