public static T InsertOrReplaceEntity <T>(this CloudTablePool tablePool, T entity) where T : class, ITableEntity { return(tablePool.Execute(table => { var insertOp = TableOperation.InsertOrReplace(entity); var tableResult = table.Execute(insertOp); return (T)tableResult.Result; })); }
/// Performs a plain merge operation for a given entity where the caller must set the e-tag on the entity public static T UpdateEntity <T>(this CloudTablePool tablePool, T entity) where T : class, ITableEntity { return(tablePool.Execute(table => { var updateOp = TableOperation.Merge(entity); var tableResult = table.Execute(updateOp); return (T)tableResult.Result; })); }
/// Performs a 'hard' delete operation, the e-tag will be set to * (so always delete) public static void Delete(this CloudTablePool tablePool, string partitionKey, string rowKey) { tablePool.Execute(table => { table.Execute(TableOperation.Delete(new DynamicTableEntity(partitionKey , rowKey , "*" , EmptyProperties))); return(true); }); }
public static T?GetEntity <T>(this CloudTablePool tablePool, string partitionKey, string rowKey) where T : ITableEntity, new() { return(tablePool.Execute(table => { var filter = TableQueryHelpers.CreatePointQueryFilterForPartitionAndRowKey(partitionKey , rowKey); var entity = table.ExecuteQuery(new TableQuery <T>().Where(filter)) .FirstOrDefault(); return entity; })); }