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

DtoGenerator - Generate C# classes from SQL queries

  • 1 min

I’m sharing DtoGenerator, a small utility to generate C# classes from any SQL query. It is designed to facilitate work with micro ORMs like Dapper.

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

Instead, DtoGenerator works with any SQL Query you can execute, no matter how complex.

csharp-dto-generator-screenshot

As a consequence, DtoGenerator does not generate information related to navigation properties, only the result’s properties 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 speed up 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