Language: EN

dtogenerator-genera-clases-de-c-a-partir-de-consultas-sql

DtoGenerator - Generate C# classes from SQL queries

I share DtoGenerator, a small utility to generate classes in C# from any SQL query. It is designed to facilitate working with micro ORM like Dapper.

There are many class generators, but most of them work from tables, views, or stored procedures.

Instead, DtoGenerator works with any SQL Query that you can execute, not matter how complex it is.

csharp-dto-generator-screenshot

As a result, DtoGenerator does not generate information related to navigation properties, only the properties of the result and their types.

DtoGenerator executes the Query in a Dataset and generates the classes from the information obtained in the result, replacing the ‘Select …’ commands with ‘Select top 1 ’ to lighten the execution.

The operation is simple. Just write the connection string, the SQL query, and press the ‘Generate’ button.

All the code is available on Github at https://github.com/luisllamasbinaburo/DtoGenerator. github-full