public void Add(TSession session) { if (session.Interims != null) { var interimCollection = GetEntityCollection(session.PhysicalSessionId); foreach (var interim in session.Interims) { try { interim.Version = 1; interim.LastUpdateDateTime = DateTime.Now; interim.SessionVersion = session.Version; interimCollection.Update(Query.EQ("_id", BsonValue.Create(interim.Id)), Update.Replace(interim), UpdateFlags.Upsert); } catch (MongoWriteConcernException ex) { // some logging throw; } } } }