Reporting External Queries

From time to time, while you are using NHibernate, you also use additional methods to query the database. The profiler provide hooks that allow you to integrate those external querying options into the profiler as well.

You can do that using the following code:

HibernatingRhinos.Profiler.Appender.CustomerQueryReporting.ReportQuery(
   sessionId: Guid.NewGuid().ToString(), // create a new session
   queryText: "select * from Users where Id = @users", // the sql 
   parameters: dbCmd.Parameters, // contains the @users parameter
   databaseTime: 10, // time in milliseconds from executing query to first row
   totalTime: 15, // time in millseconds from executing query to completing processing the query
   rowCount: 10 // number of rows returned by this query
);

This will cause the "select * from Users where Id = @users" query to show up as a new session in the profiler.