Long story short, I’m a Java developer who’s been thrown a C# project because “it’s kinda similar, right?” as we’ve lost our sole C# developer. Never done C# before. This is probably a fairly basic question, I expect it’s something fairly basic about variable scopes that’s probably not directly MiniProfiler related.
So.
I’m profiling a Razor template. It has several nested levels, roughly (pseudocode):
var profiler = MiniProfiler.Current;
var report = ViewBag.report as IEnumerable<Question>;
using (profiler.Step("Parent template"))
{
foreach (Question question in report)
{
using (profiler.Step("Question " + question.Id))
{
foreach (Question subquestion in question)
{
using (profiler.Step("Subquestion " + subquestion.Id))
{
....
}
}
}
}
}
Only the top level works. Not the nested ones. I tried redeclaring var profiler = MiniProfiler.Current;
with different variable names in each level, to no avail.
How would I do it?