Created
December 2, 2015 22:16
-
-
Save samueleresca/fafc2cb8acc8bd7107f4 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using MongoDB.Driver; | |
namespace Blog.QueryingMongoDb.Models.Repository | |
{ | |
public class MongoDbRepo | |
{ | |
//The client that manage the connection | |
public MongoClient Client; | |
//The interface that manage the database | |
public IMongoDatabase Db; | |
/// <summary> | |
/// | |
/// </summary> | |
/// <param name="url">Mongo server url</param> | |
/// <param name="database">Database name</param> | |
public MongoDbRepo(string url, string database) | |
{ | |
this.Client = new MongoClient(url); | |
//if the database is not exist, creates the database | |
this.Db = this.Client.GetDatabase(database); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment