【问题标题】:Generic table storage entity retrieval通用表存储实体检索
【发布时间】:2013-03-08 12:35:38
【问题描述】:

我正在玩 azure 表存储实体检索并获得了一个很好的 ms 示例

http://www.windowsazure.com/en-us/develop/net/how-to-guides/table-services-v17/#retrieve-range-entities

如果你无聊查看链接

// Retrieve storage account from connection string
CloudStorageAccount storageAccount = CloudStorageAccount.Parse(
CloudConfigurationManager.GetSetting("StorageConnectionString"));

// Create the table client
CloudTableClient tableClient = storageAccount.CreateCloudTableClient();

// Get the data service context
TableServiceContext serviceContext = tableClient.GetDataServiceContext();

// Specify a partition query, using "Smith" as the partition key
CloudTableQuery<CustomerEntity> partitionQuery =
(from e in serviceContext.CreateQuery<CustomerEntity>("people")
 where e.PartitionKey == "Smith"
 select e).AsTableServiceQuery<CustomerEntity>();

// Loop through the results, displaying information about the entity
foreach (CustomerEntity entity in partitionQuery)
{
Console.WriteLine("{0}, {1}\t{2}\t{3}", entity.PartitionKey, entity.RowKey,
    entity.Email, entity.PhoneNumber);
}

现在这很完美。但我想概括它..所以我想将 customerEntity 作为参数传递,people 作为参数传递(简单字符串表名) 并使其可重复使用。

所以技巧是将客户实体作为参数传递 请帮助:)

【问题讨论】:

    标签: c# azure-storage azure-table-storage


    【解决方案1】:

    所以你想知道如何创建一个接受通用对象类型的函数吗?看看http://msdn.microsoft.com/en-US/library/ms379564(v=VS.80).aspx

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-12-30
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多