/// <summary> /// Create an entity if it doesn't exist or merges the new values /// to the existing one /// </summary> /// <param name="entity"></param> public void InsertOrUpdate(T entity) { Validate.Null(entity, "entity"); var insertOrUpdateOperation = TableOperation.InsertOrMerge(entity); cloudTable.Execute(insertOrUpdateOperation); }
/// <summary> /// Creates a new entity in the table /// </summary> /// <param name="entity">The entity to store in the table</param> public void CreateEntity(T entity) { Validate.Null(entity, "entity"); var insertOperation = TableOperation.Insert(entity); cloudTable.Execute(insertOperation); }
/// <summary> /// Creates a new entity in the table /// </summary> /// <param name="entity">The entity to store in the table</param> public async Task CreateEntityAsync(T entity) { Validate.Null(entity, "entity"); var insertOperation = TableOperation.Insert(entity); TableResult result = await cloudTable.ExecuteAsync(insertOperation); System.Diagnostics.Trace.TraceInformation(String.Format("Create {0}:{1} returned {2}", entity.PartitionKey, entity.RowKey, result.Result.ToString())); }
/// <summary> /// Creates a new queue message with the given content and adds it to the queue /// </summary> /// <param name="content">The content to add to the queue message</param> public void EnQueue(byte[] content) { Validate.Null(content, "content"); var cloudQueueMessage = new CloudQueueMessage(content); cloudQueue.AddMessage(cloudQueueMessage); }
/// <summary> /// Creates a new queue message with the given content and adds it to the queue /// </summary> /// <param name="content">The content to add to the queue message</param> public async Task EnQueueAsync(byte[] content) { Validate.Null(content, "content"); var cloudQueueMessage = new CloudQueueMessage(content); await cloudQueue.AddMessageAsync(cloudQueueMessage); }
/// <summary> /// Creates new entities in the table using batching /// </summary> /// <param name="entities">The entities to store in the table</param> public async Task CreateEntitiesAsync(IEnumerable <T> entities) { Validate.Null(entities, "entities"); var batchOperation = new TableBatchOperation(); foreach (var entity in entities) { batchOperation.Insert(entity); } await cloudTable.ExecuteBatchAsync(batchOperation); }
/// <summary> /// Creates new entities in the table using batching /// </summary> /// <param name="entities">The entities to store in the table</param> public void CreateEntities(IEnumerable <T> entities) { Validate.Null(entities, "entities"); var batchOperation = new TableBatchOperation(); foreach (var entity in entities) { batchOperation.Insert(entity); } cloudTable.ExecuteBatch(batchOperation); }
/// <summary> /// Creates a new block blob and populates it from a byte array /// </summary> /// <param name="blobId">The blobId for the block blob</param> /// <param name="contentType">The content type for the block blob</param> /// <param name="data">The data to store in the block blob</param> /// <returns>The URI to the created block blob</returns> public string CreateBlockBlob(string blobId, string contentType, byte[] data) { Validate.BlobName(blobId, "blobId"); Validate.String(contentType, "contentType"); Validate.Null(data, "data"); var cloudBlockBlob = cloudBlobContainer.GetBlockBlobReference(blobId); cloudBlockBlob.Properties.ContentType = contentType; cloudBlockBlob.UploadFromByteArray(data, 0, data.Length); return(cloudBlockBlob.Uri.ToString()); }
/// <summary> /// Creates a new block blob and populates it from a stream /// </summary> /// <param name="blobId">The blobId for the block blob</param> /// <param name="contentType">The content type for the block blob</param> /// <param name="data">The data to store in the block blob</param> /// <returns>The URI to the created block blob</returns> public async Task <string> CreateBlockBlobAsync(string blobId, string contentType, Stream data) { Validate.BlobName(blobId, "blobId"); Validate.String(contentType, "contentType"); Validate.Null(data, "data"); var cloudBlockBlob = cloudBlobContainer.GetBlockBlobReference(blobId); cloudBlockBlob.Properties.ContentType = contentType; await cloudBlockBlob.UploadFromStreamAsync(data); return(cloudBlockBlob.Uri.ToString()); }
public async Task WriteStreamToFileAsync(string directoryName, string fileName, Stream content) { Validate.String(directoryName, "directoryName"); Validate.String(fileName, "fileName"); Validate.Null(content, "content"); var rootDirectory = cloudFileShare.GetRootDirectoryReference(); var directoryToUpdate = rootDirectory.GetDirectoryReference(directoryName); var file = directoryToUpdate.GetFileReference(fileName); if (!file.Exists()) { file.Create(long.MaxValue); } await file.UploadFromStreamAsync(content); }
private async Task <List <T> > ExecuteQueryAsync(TableQuery <T> query) { Validate.Null(cloudTable, "cloudTable"); List <T> entities = new List <T>(); TableContinuationToken token = null; do { TableQuerySegment <T> resultSegment = await cloudTable.ExecuteQuerySegmentedAsync(query, token); token = resultSegment.ContinuationToken; foreach (T entity in resultSegment.Results) { entities.Add(entity); } } while (token != null); return(entities); }
/// <summary> /// Create an entity if it doesn't exist or merges the new values /// to the existing one /// </summary> /// <param name="entity"></param> public async Task InsertOrUpdateAsync(T entity) { Validate.Null(entity, "entity"); var insertOrUpdateOperation = TableOperation.InsertOrMerge(entity); await cloudTable.ExecuteAsync(insertOrUpdateOperation); }
/// <summary> /// Creates a new entity in the table /// </summary> /// <param name="entity">The entity to store in the table</param> public async Task CreateEntityAsync(T entity) { Validate.Null(entity, "entity"); var insertOperation = TableOperation.Insert(entity); await cloudTable.ExecuteAsync(insertOperation); }
/// <summary> /// Deletes the given queue message from the queue /// </summary> /// <param name="cloudQueueMessage">The queue message to delete</param> public void DeleteMessage(CloudQueueMessage cloudQueueMessage) { Validate.Null(cloudQueueMessage, "cloudQueueMessage"); cloudQueue.DeleteMessage(cloudQueueMessage); }
/// <summary> /// Deletes the given queue message from the queue /// </summary> /// <param name="cloudQueueMessage">The queue message to delete</param> public async Task DeleteMessageAsync(CloudQueueMessage cloudQueueMessage) { Validate.Null(cloudQueueMessage, "cloudQueueMessage"); await cloudQueue.DeleteMessageAsync(cloudQueueMessage); }