Language: EN


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.


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 github-full