Esempio n. 1
0
        public void Save(IMaybe <TAggregate> aggregrate, bool dispatchImmediately = true)
        {
            aggregrate.Foreach(x =>
            {
                var uncommitedChanges = x.GetUncommitedChanges();
                var enumerable        = uncommitedChanges as IEvent[] ?? uncommitedChanges.ToArray();
                _eventStore.SaveStream(x.GetIdentity(), enumerable, x.GetVersion());

                enumerable.Each(a => _publisher.Publish(a, -1, dispatchImmediately));
            });
        }
Esempio n. 2
0
        public void Update(IMaybe <T> readmodel)
        {
            var session = _sessionFactory.GetCurrentSessionOrOpen();

            readmodel.Foreach(x =>
            {
                var ttt = x.GetType();

                foreach (var kkk in session.Statistics.EntityKeys)
                {
                    if (kkk.EntityName == ttt.FullName)
                    {
                        // 2 projection updates will blow up the session with a message - "a different object with the same identifier value was already associated with the session: }
                        //session.Save(x);
                        //session.Flush();
                        session.Evict(session.Get(kkk.EntityName, kkk.Identifier));
                    }
                }

                session.Update(x);
            });
        }
Esempio n. 3
0
 public void Remove(IMaybe <T> readmodel)
 {
     readmodel.Foreach(x => _sessionFactory.GetCurrentSessionOrOpen().Delete(x));
 }