INNER CODE UNIT · C#
queryList
TurnerSoftware/MongoFramework · src/MongoFramework.Profiling.MiniProfiler/MiniProfilerDiagnosticListener.cs:123
var queryList = command.IndexModel.GroupBy(w => w.Options.Name)
.Select(g => g.Key.ToString() + "\n" + string.Join("\n", g.Select(w => GetIndexModelAsString(w))));
var indexModelString = string.Join("; ", queryList);
Commands[command.CommandId] = StackExchange.Profiling.MiniProfiler.Current.CustomTiming("mongodb", indexModelString, "Index");
}
#pragma warning restore CRR0026 // Unused member
private string GetIndexModelAsString<TEntity>(CreateIndexModel<TEntity> indexModel)
{
var serializer = BsonSerializer.LookupSerializer<TEntity>();
var indexOptions = indexModel.Options;
return new BsonDocument
{
{ "Keys", indexModel.Keys.Render(serializer, BsonSerializer.SerializerRegistry) },
{ "Options", new { indexOptions.Name, indexOptions.Unique, indexOptions.Background }.ToBsonDocument() }
}.ToString();
}
}
}