public static TableOperation Retrieve <TElement>(string partitionKey, string rowkey) where TElement : ITableEntity { CommonUtility.AssertNotNull("partitionKey", partitionKey); CommonUtility.AssertNotNull("rowkey", rowkey); // Create and return the table operation. return(new TableOperation(null /* entity */, TableOperationType.Retrieve) { RetrievePartitionKey = partitionKey, RetrieveRowKey = rowkey, RetrieveResolver = (pk, rk, ts, prop, etag) => EntityUtilities.ResolveEntityByType <TElement>( pk, rk, ts, prop, etag) }); }
/// <summary> /// Adds a table operation that retrieves an entity with the specified partition key and row key to the batch operation. The entity will be deserialized into the specified class type which extends <see cref="ITableEntity"/>. /// </summary> /// <typeparam name="TElement">The class of type for the entity to retrieve.</typeparam> /// <param name="batch">The input <see cref="TableBatchOperation"/>, which acts as the <c>this</c> instance for the extension method.</param> /// <param name="partitionKey">A string containing the partition key of the entity to be retrieved.</param> /// <param name="rowkey">A string containing the row key of the entity to be retrieved.</param> /// <param name="selectedColumns">List of column names for projection.</param> public void Retrieve <TElement>(string partitionKey, string rowkey, List <string> selectedColumns = null) where TElement : ITableEntity { CommonUtility.AssertNotNull("partitionKey", partitionKey); CommonUtility.AssertNotNull("rowkey", rowkey); // Add the table operation. this.Add(new TableOperation(null /* entity */, TableOperationType.Retrieve) { RetrievePartitionKey = partitionKey, RetrieveRowKey = rowkey, SelectColumns = selectedColumns, RetrieveResolver = (pk, rk, ts, prop, etag) => EntityUtilities.ResolveEntityByType <TElement>(pk, rk, ts, prop, etag) }); }
/// <summary> /// Adds a table operation that retrieves an entity with the specified partition key and row key to the batch operation. The entity will be de-serialized into the specified class type which extends <see cref="ITableEntity"/>. /// </summary> /// <typeparam name="TElement">The class of type for the entity to retrieve.</typeparam> /// <param name="batch">The input <see cref="TableBatchOperation"/>, which acts as the <c>this</c> instance for the extension method.</param> /// <param name="partitionKey">A string containing the partition key of the entity to be retrieved.</param> /// <param name="rowkey">A string containing the row key of the entity to be retrieved.</param> public static void Retrieve <TElement>(this TableBatchOperation batch, string partitionKey, string rowkey) where TElement : ITableEntity { CommonUtils.AssertNotNull("partitionKey", partitionKey); CommonUtils.AssertNotNull("rowkey", rowkey); // Add the table operation. batch.Add(new TableOperation(null /* entity */, TableOperationType.Retrieve) { RetrievePartitionKey = partitionKey, RetrieveRowKey = rowkey, RetrieveResolver = (pk, rk, ts, prop, etag) => EntityUtilities.ResolveEntityByType <TElement>(pk, rk, ts, prop, etag) }); }