コード例 #1
0
        void DeleteUniqueProperty(IContainSagaData saga, KeyValuePair <string, object> uniqueProperty)
        {
            var id = SagaUniqueIdentity.FormatId(saga.GetType(), uniqueProperty);

            Session.Advanced.Defer(new DeleteCommandData {
                Key = id
            });
        }
コード例 #2
0
        T GetByUniqueProperty <T>(string property, object value) where T : IContainSagaData
        {
            var lookupId = SagaUniqueIdentity.FormatId(typeof(T), new KeyValuePair <string, object>(property, value));

            var lookup = Session
                         .Include("SagaDocId") //tell raven to pull the saga doc as well to save us a round-trip
                         .Load <SagaUniqueIdentity>(lookupId);

            if (lookup != null)
            {
                return(lookup.SagaDocId != null
                    ? Session.Load <T>(lookup.SagaDocId) //if we have a saga id we can just load it
                    : Get <T>(lookup.SagaId));           //if not this is a saga that was created pre 3.0.4 so we fallback to a get instead
            }
            return(default(T));
        }
コード例 #3
0
        void StoreUniqueProperty(IContainSagaData saga)
        {
            var uniqueProperty = UniqueAttribute.GetUniqueProperty(saga);

            if (!uniqueProperty.HasValue)
            {
                return;
            }

            var id        = SagaUniqueIdentity.FormatId(saga.GetType(), uniqueProperty.Value);
            var sagaDocId = sessionFactory.Store.Conventions.FindFullDocumentKeyFromNonStringIdentifier(saga.Id, saga.GetType(), false);

            Session.Store(new SagaUniqueIdentity
            {
                Id          = id,
                SagaId      = saga.Id,
                UniqueValue = uniqueProperty.Value.Value,
                SagaDocId   = sagaDocId
            });

            SetUniqueValueMetadata(saga, uniqueProperty.Value);
        }