Created
January 14, 2015 04:15
-
-
Save wcadap/6f95e91c2385b3c5bc48 to your computer and use it in GitHub Desktop.
This file contains 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; | |
using System; | |
namespace mvcMongoDB.Models | |
{ | |
public class CountryDB | |
{ | |
//For Best practice, Please put this in the web.config. This is only for demo purpose. | |
//==================================================== | |
public String connectionString = "mongodb://localhost"; | |
public String DataBaseName = "CountryDB"; | |
//==================================================== | |
public MongoDatabase Database; | |
public CountryDB () | |
{ | |
var client = new MongoClient(connectionString); | |
var server = client.GetServer(); | |
Database = server.GetDatabase(DataBaseName); | |
} | |
public MongoCollection<Country> Countries | |
{ | |
get | |
{ | |
var Countries = Database.GetCollection<Country>("Countries"); | |
return Countries; | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment