示例#1
0
        T GetByUniqueProperty <T>(string property, object value) where T : ISagaEntity
        {
            var lookupId = SagaUniqueIdentity.FormatId(typeof(T), new KeyValuePair <string, object>(property, value));

            var lookup = Session
                         //The line below is disable because of a bug in Raven 616. We can enable it when we upgrade to the lastest RavenDB
                         //.Include("SagaDocId") //tell raven to pull the saga doc as well to save us a roundtrip
                         .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));
        }
示例#2
0
        void StoreUniqueProperty(ISagaEntity saga)
        {
            var uniqueProperty = UniqueAttribute.GetUniqueProperty(saga);

            if (!uniqueProperty.HasValue)
            {
                return;
            }

            var id = SagaUniqueIdentity.FormatId(saga.GetType(), uniqueProperty.Value);

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

            SetUniqueValueMetadata(saga, uniqueProperty.Value);
        }
示例#3
0
        void StoreUniqueProperty(ISagaEntity 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);
        }
示例#4
0
        void DeleteUniqueProperty(ISagaEntity saga, KeyValuePair <string, object> uniqueProperty)
        {
            var id = SagaUniqueIdentity.FormatId(saga.GetType(), uniqueProperty);

            Session.Advanced.DatabaseCommands.Delete(id, null);
        }