Beispiel #1
0
        public IAsyncTableStorageRepository <T> Create <T>(string tableName) where T : ITableEntity, new()
        {
            if (_azureSettings.CreateIfNotExists)
            {
                throw new InvalidOperationException("Creation of resources can only be done through an asynchronous factory");
            }

            if (String.IsNullOrWhiteSpace(tableName))
            {
                throw new ArgumentNullException(nameof(tableName));
            }
            string connectionString = _connectionStringProvider.Get <IAsyncTableStorageRepository <T> >(tableName);
            IAsyncTableStorageRepository <T> result = new AsyncTableStorageRepository <T>(connectionString, tableName, _tableStorageQueryBuilder, _tableContinuationTokenSerializer, _loggerFactory.CreateLogger <AsyncTableStorageRepository <T> >());

            return(result);
        }
Beispiel #2
0
        public async Task <IAsyncTableStorageRepository <T> > CreateAsync <T>(string tableName) where T : ITableEntity, new()
        {
            if (String.IsNullOrWhiteSpace(tableName))
            {
                throw new ArgumentNullException(nameof(tableName));
            }
            string connectionString = await _connectionStringProvider.GetAsync <IAsyncTableStorageRepository <T> >(tableName);

            IAsyncTableStorageRepository <T> result = new AsyncTableStorageRepository <T>(connectionString, tableName, _tableStorageQueryBuilder, _tableContinuationTokenSerializer, _loggerFactory.CreateLogger <AsyncTableStorageRepository <T> >());

            if (_azureSettings.CreateIfNotExists)
            {
                await result.GetCloudTable().CreateIfNotExistsAsync();
            }

            return(result);
        }