コード例 #1
0
        public async Task <TAggregate> TryGetAsync(Guid aggregateId)
        {
            var partitionKey = AggregateKeysBuilder.BuildPartitionKey(aggregateId);
            var rowKey       = AggregateKeysBuilder.BuildRowKey(aggregateId);

            var entity = await _storage.GetDataAsync(partitionKey, rowKey);

            if (entity != null)
            {
                return(await _mapEntityToAggregate(entity));
            }

            return(null);
        }
コード例 #2
0
        public async Task <TAggregate> GetOrAddAsync(Guid aggregateId, Func <TAggregate> newAggregateFactory)
        {
            var partitionKey = AggregateKeysBuilder.BuildPartitionKey(aggregateId);
            var rowKey       = AggregateKeysBuilder.BuildRowKey(aggregateId);

            var startedEntity = await _storage.GetOrInsertAsync(
                partitionKey,
                rowKey,
                () =>
            {
                var newAggregate = newAggregateFactory();

                return(_mapAggregateToEntity(newAggregate));
            });

            return(await _mapEntityToAggregate(startedEntity));
        }