【发布时间】:2019-03-16 02:29:42
【问题描述】:
我有一个带有 Azure 表存储的数据库,我在其中存储具有各种属性的实体,并且一切运行良好。但是,当我尝试添加新属性时,它根本不会被存储。我的 InsertEntity 代码如下所示:
LunchDateEntity entity = new LunchDateEntity(ID);
try{
AppStorage storage = new AppStorage(TABLENAME);
entity.setProperty1(prop1)
entity.setProperty2(prop2)
entity.setProperty3(prop3)
entity.setNewProperty(newProp)
TableOperation operation = TableOperation.insert(entity);
m_table.execute(operation);
}
catch(...) {...}
Prop 1,2,3 是我之前拥有的实体,它们被添加到表存储中,但是,newProp 并没有在表存储中显示。
我尝试在构建实体时对属性进行硬编码,但无济于事。
我的实体类看起来像:
public class myEntity extends TableServiceEntity {
public static final String TABLENAME = "myTable";
public static final String PARTITION_KEY = "part1";
public String m_prop1 = "";
public String m_prop2 = "";
public String m_prop3 = "";
public String m_newProp = "";
public myEntity() {
this.partitionKey = PARTITION_KEY;
}
public void setProp1(String prop1) {
m_prop1 = prop1;
}
public String getProp1() {
return m_prop1;
}
public void setNewProp(String newProp) {
m_newProp = newProp;
}
等等所有属性。他们看起来都一样。
我是否误解了插入功能的工作原理?有什么想法为什么这不起作用?
提前致谢
【问题讨论】:
-
无法在我这边重现您的问题。您可以使用 Fiddler 捕获插入请求正文以查看您的实体吗?
-
您使用的是哪个表存储版本?新属性不显示或只是空值?
-
这很奇怪......我的代码位于函数应用程序中,我插入带有 HTTP POST 请求的实体。如果我对实体进行字符串化并返回它,则 newProp 会显示在 Postman 的响应中。在我看来,问题出在插入功能上。我将尝试将 TableStorage 更新到 1.4.2,看看会发生什么。
-
当然,我也会尝试在 azure http 触发函数中插入实体。
-
更新没有任何区别。该值不为空,该表根本没有该属性的列。编辑:我有所有属性的设置器和获取器,但 newProp 设置/获取是从早期有效的道具复制+粘贴。