Пример #1
0
        /// <summary>
        /// Gets the Mongo collection of the DataEntity requested. If the collection does not already exist, it will be created.
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <returns></returns>
        public IMongoCollection <T> GetCollection <T>() where T : DataEntityBase
        {
            lock (CollectionCache)
            {
                if (!CollectionCache.ContainsKey(typeof(T)))
                {
                    Logger.Trace($"{nameof(MongoStore)}.{nameof(GetCollection)}<{typeof(T).Name}>",
                                 new LogItem("Action", "Not cached, call GetOrCreateCollection"));
                    GetOrCreateCollection <T>();
                }

                return((IMongoCollection <T>)CollectionCache[typeof(T)]);
            }
        }