top button
Flag Notify
    Connect to us
      Facebook Login
      Site Registration Why to Join

Facebook Login
Site Registration

get all the collection names from MongoDb server using C#

+1 vote
801 views

I am trying to get all the collection names from MongoDb server using C# code using db.GetCollectionNames() method.

I have 12 collections in my database, but the above method returns an empty list. I have verified that I am referring to the correct database. What am I doing wrong? Or if there is an alternate way?

posted May 18, 2016 by Kiran

Share this question
Facebook Share Button Twitter Share Button Google+ Share Button LinkedIn Share Button Multiple Social Share Button

1 Answer

+1 vote

Hi,Try this command on cmd to get collection names of current database:

  -> db.ListCollectionsAsync().Result.ToListAsync<BsonDocument>().Result
answer May 18, 2016 by Shivam Kumar Pandey
"The GuidRepresentation for the reader is CSharpLegacy, which requires the binary sub type to be UuidLegacy, not UuidStandard."
Similar Questions
0 votes

I want to connect a particular MONGODB database to c# application using Web.config.
Please tell me how to do it?

0 votes

How to get all query which related 1 collection in mongodb? for oracle,we can get all query from system view like v$sql, but I am not sure if mongodb have this system view to see all query related 1 special collection?

Contact Us
+91 9880187415
sales@queryhome.net
support@queryhome.net
#280, 3rd floor, 5th Main
6th Sector, HSR Layout
Bangalore-560102
Karnataka INDIA.
QUERY HOME
...