通用表存储实体检索



我正在玩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作为一个参数,人作为参数(简单字符串表名)并使其可重复使用。

所以技巧是传递customerentity作为参数请帮忙:)

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

相关内容

  • 没有找到相关文章

最新更新