MongoDB Basic Primer 003--Use the official drive operation Mongo,c#

Source: Internet
Author: User
Tags bulk insert install mongodb mongodb driver

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#

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.