Created
April 15, 2013 10:20
-
-
Save baio/5387153 to your computer and use it in GitHub Desktop.
mongo connect, update
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
var connectionString = ConfigurationManager.AppSettings["MONGO_URI"]; | |
if (connectionString != null) | |
{ | |
var hostName = Regex.Replace(connectionString, "^(.*)/(.*)$", "$1"); | |
var dbName = Regex.Replace(connectionString, "^(.*)/(.*)$", "$2"); | |
var server = MongoServer.Create(hostName); | |
server.Connect(); | |
var db = server.GetDatabase(dbName); | |
var trade = ConvertTrade2StorageModel(Trade); | |
var coll = db.GetCollection<Trade>("trades"); | |
coll.Save(trade); | |
server.Disconnect(); | |
} | |
public class Trade | |
{ | |
[BsonRepresentation(BsonType.ObjectId)] | |
public string _id { get; set; } | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment