The previous five comparisons have received positive feedback from everyone, as well as individual experts who have written me the code I write.
I wrote the query method of the performance problems, I think, if MONGO is not delayed loading, then my query is really a problem, it became a query out all the data and then two times to filter.
Maybe this is also the habitual use of the Entity Framework framework. Today hurriedly carried out a bit of code, now posted out, the province of the wrong way to mislead everyone, and then thank you for my criticism.
Public StaticUser GetById (ObjectId ID) {mongodatabase db=mongohelper.getconnection (); Mongocollection Collection= db. Getcollection<user> ("User"); returnCollection. Findonebyidas<user>(ID); } Public StaticUser Getbyname (stringname) {Mongodatabase db=mongohelper.getconnection (); Mongocollection Collection= db. Getcollection<user> ("User"); varquery = Query.and (Query.eq ("UserName", name)); returnCollection. Findoneas<user>(query); } Public Staticmongocollection GetCollection () {Mongodatabase db=mongohelper.getconnection (); returnDb. Getcollection<user> ("User"); } Public Static BOOLishasuser (imongoquery query) {mongodatabase db=mongohelper.getconnection (); Mongocollection Collection= db. Getcollection<user> ("User"); returnCollection. Count (query) >0; } Public Static voidUpdate (imongoquery query,imongoupdate update) {Mongodatabase db=mongohelper.getconnection (); Mongocollection Collection= db. Getcollection<user> ("User"); Collection. Update (query, update); }
From a flexible point of view I think it's okay to pass the Imongoquery type parameter, which is much more flexible than passing string strings, which I usually write when I call this function.
var queryname = Query.and (Query.eq ("UserName", Cwsnuser)); // Verify that the user is present if (Daluser.ishasuser (queryname)) { return Content ("2"); // Duplicate user name }
C # Development MONGO note Sixth