Beispiel #1
0
        /// <summary>
        /// AddEntity Wrapper.
        /// </summary>
        /// <param name="tableName">TableName.</param>
        /// <param name="entity">Entity.</param>
        /// <param name="cancellationToken">CancellationToken.</param>
        /// <returns>Response</returns>
        public async Task <Azure.Response> AddEntityAsync(string tableName, TableEntity entity, CancellationToken cancellationToken = default)
        {
            TableClient tableClient;

            // Look for cache key.
            if (!this.memoryCache.TryGetValue(tableName, out tableClient))
            {
                await this.CreateTableIfNotExistsAsync(tableName).ConfigureAwait(false);

                tableClient = new TableClient(
                    this.tableStorageConfig.ConnectionString,
                    tableName);

                // Save data in cache.
                this.memoryCache.Set(tableName, tableClient);
            }

            Azure.Response res = tableClient.AddEntity(entity, cancellationToken);
            return(res);
        }