Home

Monday, 11 July 2016

What is MongoDB? How to Connect with this using C#

MongoDB-
1) Mongo DB is open Source Database written in C++. It is schema less data base.i.e no row and column available,
2) Mongo DB store data in JSon Format.
3) MongoDB is easy to install-able.
4) MongoDb Stored data in collection format .

Where it used-
1) Its used in Big Data.
2) Schema less data structure means where no of field not fixed.

MongoDb stored data in key and value format.
e.g.

{
    'id' : 1,
    'name' : { 'first' : 'Pankaj', 'last' : 'Singh' },
    'Address' : 'Delhi',
    'Education' : [
        {
            'BCA' : 'xyz',
            'MCA' : 'abc',
        }
    ]
}

Connection with MongoDB using C#-
Step 1-MongoDB officially provide a driver to connect with c# name is MongoDB C# Driver.
Download it .we can download this from below link-
https://docs.mongodb.com/ecosystem/drivers/csharp/

Step 2-Add Below DLL reference in application-
1) MongoDB.Bson.dll
2) MongoDB.Driver.dll
3) MongoDB.Driver.Core.dll

Step 3-Add below package in application-
1) using MongoDB.Bson;
2) using MongoDB.Driver;

After that add below code in application-

protected static IMongoClient client;
protected static IMongoDatabase database;

client=new MongoClient();
database=client.getDatabase("databasename");

No comments:

Post a Comment