Beispiel #1
0
        private String GetIndexName(IMongoIndexKeys keys)
        {
            var keysdocument = keys.ToBsonDocument();

            return(keysdocument
                   .Select(k => k.Name + "_" + k.Value.ToString())
                   .Aggregate((s1, s2) => s1 + "_" + s2));
        }
Beispiel #2
0
        public override WriteConcernResult CreateIndex(IMongoIndexKeys keys, IMongoIndexOptions options)
        {
            var sw = new Stopwatch();

            sw.Start();
            var result = base.CreateIndex(keys, options);

            sw.Stop();

            string commandString = options != null
                ? string.Format("db.{0}.ensureIndex(keys, options)\n\nkeys = {1}\n\noptions = {2}", Name, keys.ToBsonDocument(), options.ToBsonDocument())
                : string.Format("db.{0}.ensureIndex(keys, options)\n\nkeys = {1}", Name, keys.ToBsonDocument());

            ProfilerUtils.AddMongoTiming(commandString, sw.ElapsedMilliseconds, ExecuteType.Command);

            return(result);
        }