Last active
December 4, 2015 01:31
-
-
Save BrianJVarley/93a0dfbb4457a179dab3 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
private static List<Country> countryList = new List<Country>(); | |
public void LoadDb() | |
{ | |
var countrycollection = StartCountryConnection(); | |
try | |
{ | |
countryList = countrycollection.AsQueryable<Country>().Where<Country>(sb => sb.Name == "Antartica").ToList(); | |
} | |
catch (MongoException ex) | |
{ | |
//Log exception here: | |
System.Windows.MessageBox.Show("A connection error occurred: " + ex.Message, "Connection Exception", MessageBoxButton.OK, MessageBoxImage.Warning); | |
} | |
} | |
public IMongoCollection<Country> StartCountryConnection() | |
{ | |
var client = new MongoClient(connectionString); | |
var database = client.GetDatabase("orders"); | |
//Get a handle on the countries collection: | |
var countrycollection = database.GetCollection<Country>("countries"); | |
return countrycollection; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment