1 回答
![?](http://img1.sycdn.imooc.com/54584d6100015f5802200220-100-100.jpg)
TA贡献1828条经验 获得超4个赞
在您的客户实体类中,您正在调用构造函数
public CustomerEntity(string lastName, string firstName)
{
this.PartitionKey = lastName;
this.RowKey = firstName;
}
因此,当您初始化一个新对象时,您会传递两个参数(如构造函数中定义的)firstname和lastname.
新的
这些是由构造函数按名称设置的,并且在它们的上下文之外(即在表存储中)没有任何意义。
CustomerEntity customer1 = new CustomerEntity("NoSolution", "Smith");
在您的代码中,您需要做的就是将构造函数更改为
public CustomerEntity(string requesterName, string uniqueRowKey)
{
this.PartitionKey = requesterName ;
this.RowKey = uniqueRowKey;
}
您的 RowKey 必须是唯一的,并且您的分区键用于通过对相似类型的行进行分组来使搜索更容易。然后你可以像这样传递给你的构造函数:
string rowKey = Guid.NewGuid().ToString("N"); //This give you a unique guid with no hyphens.
CustomerEntity customer1 = new CustomerEntity("John Smith", rowKey);
这将分别将您的实体插入到 Partition Key 和 Row Key 中。
这就是你要找的东西吗?
- 1 回答
- 0 关注
- 204 浏览
添加回答
举报