protected virtual T Put(T t, ICriterion criterion, IContext context) { if (Collection != null) { MongoUpdate update = PutQuery(t, criterion, context); if (update != null && update.Query != null && update.Update != null) { WriteConcernResult result = Collection.Update(update.Query, update.Update); return(t != null ? t : Collection.FindOneAs <T>(update.Query)); } else { if (t != null) { Collection.Save <T>(t); return(t); } else if (criterion != null) { IMongoQuery whereQuery = UsesMongoObjectId ? QueryByObjectId(criterion) : QueryByModelId(criterion); IMongoUpdate patchUpdate = new UpdateDocument(); Collection.Update(whereQuery, criterion.ToMongoPatch()); return(Collection.FindOneAs <T>(whereQuery)); } } } return(t); }
private void btnUpdateFighter_Click(object sender, EventArgs e) { MongoUpdate update = new MongoUpdate(); try { FighterProfile fighter = new FighterProfile() { _id = update_id, Name = txtUpdateName.Text.ToString(), Age = Convert.ToInt32(txtUpdateAge.Text.ToString()), WinLossRecord = new FightRecord() { Wins = Convert.ToInt32(txtUpdateWins.Text.ToString()), Losses = Convert.ToInt32(txtUpdateLosses.Text.ToString()), Draws = Convert.ToInt32(txtUpdateDraws.Text.ToString()), }, Nickname = txtUpdateNickName.Text, Height = Convert.ToDouble(txtUpdateHeight.Text.ToString()), Weight = Convert.ToDouble(txtUpdateWeight.Text.ToString()), FightStyle = new FightStyle() { Style = txtUpdateFightStyle.Text.ToString() }, WeightClass = txtUpdateWeightClass.Text }; update.updateFighter(fighter); } catch (Exception ex) { MessageBox.Show("Please ensure all fields are filled in!"); } }
public void ReplaceOne() { var up = new MongoUpdate(); up.ReplaceOne(); }
public void UpdateMany() { var up = new MongoUpdate(); up.UpdateMany(); }
public void UpdateOneManyMatched() { var up = new MongoUpdate(); up.UpdateOneManyMatched(); }
public void UpdateOne2() { var up = new MongoUpdate(); up.UpdateOne2(); }