MongoDB.Driver.Database.GetCollectionNames C# (CSharp) Метод

GetCollectionNames() публичный Метод

public GetCollectionNames ( ) : List
Результат List
        public List<String> GetCollectionNames()
        {
            IMongoCollection namespaces = this["system.namespaces"];
            ICursor cursor = namespaces.Find(new Document());
            List<String> names = new List<string>();
            foreach (Document doc in cursor.Documents){
                names.Add((String)doc["name"]); //Fix Me: Should filter built-ins
            }
            return names;
        }

Usage Example

        public void TestExecuteUsing()
        {
            String tempcollname = null;

            using (MapReduceBuilder mrb = mrcol.MapReduceBuilder().Map(mapfunction).Reduce(reducefunction)){
                MapReduce mr = mrb.Execute();
                Assert.IsNotNull(mr.Result);
                Assert.IsTrue(mr.Result.Ok);
                tempcollname = tests.Name + "." + mr.Result.CollectionName;
                bool found = false;
                Assert.IsTrue(tests.GetCollectionNames().Contains(tempcollname));
            }
            Assert.IsFalse(tests.GetCollectionNames().Contains(tempcollname));
        }
All Usage Examples Of MongoDB.Driver.Database::GetCollectionNames