Last active
December 12, 2015 02:59
-
-
Save plaurin/4703605 to your computer and use it in GitHub Desktop.
Example using MiniProfiler
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
MiniProfilerEF.Initialize_EF42(); // When using Code First | |
ConsoleProfiling.Start(); | |
using (StackExchange.Profiling.MiniProfiler.Current.Step("StepName")) | |
{ | |
using (var context = new Context()) | |
{ | |
var result = context.Entities | |
.Where(p => p.Property.StartsWith("Value")) | |
.ToList(); | |
} | |
} | |
foreach (var sqlTiming in ConsoleProfiling.StopAndGetProfiler().GetSqlTimings()) | |
{ | |
Console.WriteLine("Duration: " + sqlTiming.DurationMilliseconds); | |
Console.WriteLine(sqlTiming.CommandString); | |
if (sqlTiming.Parameters != null) | |
{ | |
foreach (var parameter in sqlTiming.Parameters) | |
Console.WriteLine(parameter.Name + ": " + parameter.Value); | |
} | |
Console.WriteLine("------------------"); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment