Skip to content

Instantly share code, notes, and snippets.

@UberMouse
Last active December 26, 2015 20:39
Show Gist options
  • Save UberMouse/7210195 to your computer and use it in GitHub Desktop.
Save UberMouse/7210195 to your computer and use it in GitHub Desktop.
public void InsertGames(params SteamGame[] game)
{
var collection = GetGamesCollection();
try
{
collection.InsertBatch(game, WriteConcern.Acknowledged);
}
catch (MongoCommandException ex)
{
var x = ex;
}
}
public IEnumerable<SteamGame> RetrieveGames(params string[] appIds)
{
var collection = GetGamesCollection();
return collection.FindAs<SteamGame>(Query<SteamGame>.In(x => x.AppId, appIds.Select(x => new BsonString(x))));
}
private MongoCollection<SteamGame> GetGamesCollection()
{
var client = (ConfigurationManager.AppSettings["onAzure"] == "true") ? new MongoClient(connectionString) : new MongoClient();
var database = client.GetServer()[dbName];
return database.GetCollection<SteamGame>(collectionName);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment