I have integrated Entity Framework and CodeFirstStoredProc library in my project. I want to log the queries executed by both the libraries. Previously I was using Database.Log delegate provided by EF but as I want to log query from other libraries also, I decided to integrated Miniprofiler for the same.
I used below code to get the query log in result variable:
MiniProfilerEF6.Initialize();
MiniProfiler.StartNew("Test");
using (MiniProfiler.Current.Step("Level 1"))
{
DbConnection spConnection = new System.Data.SqlClient.SqlConnection(ConfigurationManager.ConnectionStrings["DefaultConnection"].ConnectionString);
ProfiledDbConnection profileSpConnection = new ProfiledDbConnection(spConnection, MiniProfiler.Current);
using (EfDataContext db = new EfDataContext(profileSpConnection))
{
List<Domain.PersonEntity> data = db.Persons.ToList();
}
using (StoredProcedureContext db = new StoredProcedureContext(profileSpConnection))
{
List<GetPersonResult> data = db.GetPerson.CallStoredProc(new Domain.GetPersonParameter { IsActive = true }).ToList<GetPersonResult>();
}
string result = MiniProfiler.Current.RenderPlainText();
}
MiniProfiler.Current.Stop();
I expected the output query with all the details but unfortunately I am getting below result:
Manprit-PC at 11/15/2018 2:24:27 PM
Test = ms
> Level 1 = ms (sql = 45ms in 12 cmds)
Am I missing something for the implementation?
This is just how current version of
MiniProfilerExtensions.RenderPlainText()renders custom timing information. Custom timings are created usingCustomTiming()rather thenStep(), they typically are sort of leaf measurements in a MiniProfiler hierarchy such as database interaction or HTTP requests.You can easily customize rendering process and render verbose information about custom timings:
Example implementation:
Also note that by default in order to render MiniProfiler report with all timings you need to call
Stop()first. You can customize this too by calculating timings so far in a report.