当我尝试此代码时
public static async Task<CustomerEntity> RetrieveEntityUsingPointQueryAsync(CloudTable table, string partitionKey, string rowKey)
{
try
{
TableOperation retrieveOperation = TableOperation.Retrieve<CustomerEntity>(partitionKey, rowKey);
TableResult result = await table.ExecuteAsync(retrieveOperation);
CustomerEntity customer = result.Result as CustomerEntity;
if (customer != null)
{
Console.WriteLine("\t{0}\t{1}\t{2}\t{3}", customer.PartitionKey, customer.RowKey, customer.Email, customer.PhoneNumber);
}
// Get the request units consumed by the current operation. RequestCharge of a TableResult is only applied to Azure CosmoS DB
if (result.RequestCharge.HasValue)
{
Console.WriteLine("Request Charge of Retrieve Operation: " + result.RequestCharge);
}
return customer;
}
catch (StorageException e)
{
Console.WriteLine(e.Message);
Console.ReadLine();
throw;
}
}
说
TableQuery通用类型必须提供默认的无参数 构造函数Microsoft.Azure.Cosmos.Table.StorageException
答案 0 :(得分:1)
错误消息指出,您需要为CustomerEntity
类使用无参数构造函数。
只需在您的CustomerEntity类中添加以下代码,即可解决此问题:
public CustomerEntity()
{
}