This article introduces briefly, using the official driver to operate MongoDB. As for the MongoDB native additions and deletions to change the statement, and so later to learn slowly.
One, the operation of MongoDB Drive mainly have two
1. Official driver: https://github.com/mongodb/mongo-csharp-driver/downloads, newer or more timely, has now supported the large-sector LINQ syntax.
2.samus Drive: Https://github.com/samus/mongodb-csharp/downloads. This seems to have not been updated for a long time, it is estimated to be abandoned it. (PS: It is said that used to be very NB AH)
Driver Download: One way is to download directly using the above connection. The students who use VS development know that our powerful vs has a package management tool (NuGet) that is very comfortable to use. Now let's show you how to use NuGet to install the MongoDB driver.
Open NuGet, enter MONGO, install Mongodb.driver,mongocsharpdriver. Please see:
Second, increase and revise the operation.
1. New
Static voidMain (string[] args) { stringConnectionString ="mongodb://localhost:27017"; varClient =Newmongoclient (connectionString); varDatabase = client. Getdatabase ("Local"); varCollection = database. Getcollection<person> (" Person"); //BULK INSERT 1000 data for(inti =0; I < +; i++) {person P=NewPerson (); P.age= i%Ten+1; P.createtime=DateTime.Now; P.name="RJ"+i; Collection. Insertone (P); } console.readkey (); }
1000 New Data
2. Enquiry
MongoDB Basic Primer 003--Use the official drive operation Mongo,c#