private static void InsertDocument() { MongoCollection col = Init(); BsonDocument b = new BsonDocument(); b.Add("Uid", 120); b.Add("Name", "liuwq"); b.Add("Password", "123"); col.Insert(b); b.Add("method", "InsertDocument"); MongoLogHelper.Instance().LogForMongo(b); }
public static MongoLogHelper Instance() { if (_Instance == null) { lock (sysObj) { if (_Instance == null) { _Instance = new MongoLogHelper(); } } } return(_Instance); }
private static void Insert() { MongoCollection col = Init(); for (int i = 0; i < 10; i++) { Users users = new Users(); users.Name = "liu" + i.ToString(); users.Sex = "woman"; users.Age = i + 1; //获得Users集合,如果数据库中没有,系统会自动新建一个 //执行插入操作 col.Insert <Users>(users); BsonDocument b = (BsonDocument)users; b.Add("method", "Insert"); MongoLogHelper.Instance().LogForMongo(b); } }