コード例 #1
0
        /// <summary>
        /// Asynchronously retrieves all domain entities within a given Index.
        /// </summary>
        /// <param name="indexKey">Key to be used as the index. If it's not a string it will be serialized to JSON first and then used as the index name key (a.k.a. Partition Key)</param>
        /// <returns></returns>
        public async Task <List <TDomainEntity> > GetAllItemsFromIndexAsync(object indexKey)
        {
            if (indexKey is string key)
            {
                var entities = await TableOperationsService.GetByPartitionKeyAsync(key).ConfigureAwait(false);

                return(entities.Select(tableEntity => tableEntity.DomainObjectInstance).ToList());
            }
            var serializedPartitionKey = JsonConvert.SerializeObject(indexKey);
            var ents = await TableOperationsService.GetByPartitionKeyAsync(serializedPartitionKey).ConfigureAwait(false);

            return(ents.Select(azureTableEntity => azureTableEntity.DomainObjectInstance).ToList());
        }
コード例 #2
0
        /// <summary>
        /// Gets all the entities via the <see cref="DefaultIndex"/> asynchronously. This is usually the index that retrieves items by ID so all
        /// entities should be unique by default
        /// </summary>
        /// <returns></returns>
        public async Task <List <TDomainEntity> > GetAllAsync()
        {
            var partition = await TableOperationsService.GetByPartitionKeyAsync(_defaultIndexDefinitionName).ConfigureAwait(false);

            return(partition.Select(cte => cte.DomainObjectInstance).ToList());
        }
コード例 #3
0
        /// <summary>
        /// Deletes all instances from a particular index. Under the hood this is deleting everything inside
        /// a Table Partition.
        /// </summary>
        /// <param name="indexNameKey"></param>
        /// <returns></returns>
        public async Task DeleteAllItemsFromIndexAsync(string indexNameKey)
        {
            var entities = await TableOperationsService.GetByPartitionKeyAsync(indexNameKey).ConfigureAwait(false);

            await TableOperationsService.DeleteAsync(entities.ToArray()).ConfigureAwait(false);
        }