简体   繁体   中英

Can you tag generated SQL from an ORM for troubleshooting purposes?

We heavily use ORMs in our web application (EF and LLBlGen) and we have a DBA helping us improve the performance of the application by finding queries that are causing the most problems. We have a lot of linq queries accessing the database and some are quite complex.

Is there a way to tag the generated SQL with some identifier from Linq queries so that if the DBA finds some bad sql we can then easily go find the linq statements that generated it.

Thanks to @ErikEj for pointing me in the write direction. For EF Core I can use Query Tags https://docs.microsoft.com/en-us/ef/core/querying/tags

For LLBLGen I can use the MarkWithTag() extension method they provide for IQueryable. https://www.llblgen.com/Documentation/5.5/LLBLGen%20Pro%20RTF/Using%20the%20generated%20code/Linq/gencode_linq_generalusage.htm#query-tagging

Entity Framework appears more difficult and doesn't have a specific method to achieve the desired outcome and required adding a redundant select or where clause. How to "tag" Entity Framework Queries

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM