Skip to content

Instantly share code, notes, and snippets.

@samueleresca
Created December 2, 2015 22:16
Show Gist options
  • Save samueleresca/fafc2cb8acc8bd7107f4 to your computer and use it in GitHub Desktop.
Save samueleresca/fafc2cb8acc8bd7107f4 to your computer and use it in GitHub Desktop.
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