top button
Flag Notify
    Connect to us
      Site Registration

Site Registration

get all the collection names from MongoDb server using C#

+1 vote
1,459 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 LinkedIn 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?

...