/// <summary> /// 更新实体 /// </summary> /// <param name="user"></param> public static void Update(StaffCustomer user) { try { using (Mongo mongo = new Mongo(_connectionString)) { mongo.Connect(); var db = mongo.GetDatabase(_dbName); var collection = db.GetCollection <StaffCustomer>(); // 更新对象 collection.Update(user, item => item.Id == user.Id); } } catch (Exception ex) { log.Error(ex); } }
public ActionResult Create(StaffCustomer staffCustomer) { staffCustomer.Id = ObjectId.NewObjectId().ToString(); MongoBase.Insert(staffCustomer); return(RedirectToAction("Index")); }