New Relic .NET agent instruments and groups your application's SQL queries. Normally, the .NET agent will automatically assign a name to a query based on the properties of the query. Alternatively, you can assign a custom name to a query.
How to name a query
All SQL versions supported by our .NET agents can be given a custom name.
To give a name to a query, you add a comment to the query text with a format like /* NewRelicQueryName: myQueryName */
. Here's an example of adding that to an app's code:
var connection = new MySqlConnection(mySqlConnectionString);var command = new MySqlCommand("/* NewRelicQueryName: My query name */ SELECT date FROM dates", connection);
Find named queries
Your database and query data can be found on the Databases UI page. A named query will appear with its name in brackets. Here's an example of that:
Troubleshooting
Not seeing your query data in New Relic? See our troubleshooting docs.