Esempio n. 1
0
        public void Save(EventSubscription subscription)
        {
            var key = subscription.GetHashCode();
            subscription.Id = key;
            var keyAsString = key.ToString();
            using (var session = _documentStore.OpenSession())
            {
                using (new TransactionScope(TransactionScopeOption.Suppress))
                {
                    var saving = true;

                    while (saving)
                    {
                        try
                        {
                            session.Store(subscription);
                            session.SaveChanges();
                            saving = false;
                        }
                        catch (ConcurrencyException)
                        {
                            var existing = session.Load<EventSubscription>(keyAsString);
                            if (existing.LastEventId > subscription.LastEventId)
                                saving = false;
                        }
                    }
                }
            }
        }
Esempio n. 2
0
 public void Save(EventSubscription subscription)
 {
     subscription.Id = subscription.GetHashCode();
     _collection.Save(subscription);
 }