After I use the database. GetCollectionNames ()) for less than a collection of code roughly as follows:
Public void Connect (string address, string port, string username, string password)
{
String strconn=the string. Format (" mongo://{0}, {1} ", the address and port);
This. MServer=MongoServer. Create (strconn);
}
This is the connection methods, here I am sure the connection is successful
Public MongoDBTree GetMongoDBTree ()
{
List
Return this. BuildTree (DBS);
}
Access to the database name
Private MongoDBTree BuildTree (List
{
MongoDBTree tree=new MongoDBTree ();
Tree. The Name=mServer. The Instance. The Address. The ToString ();
Tree. The NodeType=MongoDBTreeNodeType. Server;
Tree. The Children=new List
The foreach (string db in DBS)
{
MongoDBTree dbTree=new MongoDBTree ();
DbTree. Name=db;
DbTree. NodeType=MongoDBTreeNodeType. Docmenu;
DbTree. Children=new List
MongoDatabase database=this. MServer. GetDatabase (db);
Foreach (string item in the database. GetCollectionNames ())
{
MongoDBTree itemTree=new MongoDBTree ();
ItemTree. Name=item;
ItemTree. NodeType=MongoDBTreeNodeType. Docmenu;
DbTree. Children. The Add (itemTree);
}
Tree. The Children. The Add (dbTree);
}
Return the tree;
}
Mainly the foreach (string item in the database. The GetCollectionNames ())
API is 2.2.0 mongo is 3.2.4. Net4.5
API GetDatabase (db) method will create a if there is no database, this method also is really a wonderful work of
Don't know what's the problem, the great god for help
CodePudding user response:
Is your problem solved?CodePudding user response:
I found a reason, not framework 4.0, GetCollectionNames (less than) data, into framework 4.5,