请推荐关于创建从Azure表存储读取数据的控制台应用程序的好文档。我遵循了 https:/www.youtube.comwatch?v=z96fIv3RQBo 并创建了一个示例控制台应用程序,如下所示。在运行控制台时,我看到'ReceivedBadRequest'错误。
class Program
{
const string StorageAccountName = "";
const string StorageAccountKey = "";
static void Main(string[] args)
{
var storageAccount = new CloudStorageAccount(new StorageCredentials(StorageAccountName, StorageAccountKey), false);
var tableaa = storageAccount.CreateCloudTableClient().GetTableReference("Table1");
var result = tableaa.ExecuteAsync(TableOperation.Retrieve<Person>("<partition-key>", "<row-key>"));
var entity = result.Result;
Console.WriteLine(entity);
}
}
class Person : TableEntity
{
private int customerID;
private string LocationAreaCode;
private string PersonnelSubAreaCode;
private string PersonStatusCode;
public void AssignRowKey()
{
this.RowKey = customerID.ToString();
}
public void AssignPartitionKey()
{
this.PartitionKey = "<partition-key";
}
}
你的Person类中缺少一个无参数的构造函数。
请按以下方式修改Person类。
class Person : TableEntity
{
private int customerID;
private string LocationAreaCode;
private string PersonnelSubAreaCode;
private string PersonStatusCode;
public Person()
{
}
//other code
}
更多细节,请参考这个 正式文件.