MongoDB with C#

 

Modern projects need to manipulate with huge data amount, as result the necessity of high scalability and  high performance is very actual and always grows.

RDBMS databases cannot supply ultimate solution and alternative concepts like in NoSQL systems look very interesting.

 

The first interesting option is key-value stores like Google Big Table or Cassandra that provide fast and extremely large-scale solution but you can forget the comfort work with SQL queries like in RDBMS databases.  

 

Another option that tries to combine between advantages of RDBMS databases and key-values stores  is document-oriented databases like MonogDB.

 

MongoDB is development by commercial company as open-source project written in C++.

There are a lot of documentation, tutorials and samples on project site. 

 

MongoDB itself is a scalable, high-performance, schema-free, document-oriented database 

that supports dynamic queries in JSON-style format, indexes, replication, sharding, MapReduce.

 

MonogDB provides interface based on native drivers that exist for most environments: C, C++,Java,Python,Ruby...

 

For working with MonogoDB from Dot.Net there is open-source project mongodb-csharp that has in addition LINQ capability.

 

Create DB and Insert data:

Mongo mongo = new Mongo();

mongo.Connect();

IMongoCollection postsTbl = mongo.getDB("BlogDB").GetCollection("Posts");

 

Document post = new Document();

post["Tittle"] = "Tittle1";

post["Timestamp"] = DateTime.Now;

postsTbl.Insert(post);

 

Queries:

Document spec = new Document();

spec["Tittle"] = "Tittle1";

Document myPost = postsTbl.FindOne(spec);

 

or with LINQ

 

IMongoQuery query = postsTbl.AsQueryable();

var docs = query.Where(doc => doc["Tittle"] == "Tittle 1");

 

References:

Project site: http://www.mongodb.org/

Mongodb-csharp - A driver written in c# to connect to MongoDB: http://github.com/samus/mongodb-csharp

 

 

 

Thank you for your interest!

We will contact you as soon as possible.

Send us a message

Oops, something went wrong
Please try again or contact us by email at info@tikalk.com