Hi, I’ve built out a process for generating database DTOs using AutoQueryFeature’s GenerateCrudServices combined with TypeFilter and TableSchemasFilter delegate methods. This works great for tables, but we also wanted to generate DB DTOs for views that we have in the same schemas.
Is there anything that currently supports this or is there a plug-in point that we could hook into and write our own custom code to handle that? If not, what approach would you recommend? Thanks!
Not currently, at this point the place to do it would be to control your configured DialectProvider and overrride ToTableNamesStatement to include views when it queries the database metadata. This will be different per database vendor, but this is where the TableSchema type is populated from.
One last note in case this is useful for others. I added the following code to my GenerateCrudServices’s TableSchemasFilter delegate method so that it would not include any columns captured as a result of table join statements in the view:
Also I’ve since added GetTableNames and GetTableColumns filter in GenerateCrudServices to make it easier to customize what tables and columns are generated without implementing a custom DialectProvider.
Here’s an example of overriding and providing custom implementations that match the default behavior: