1 回答
TA贡献1786条经验 获得超11个赞
根据我的测试,我认为这是因为名称规则。我测试了添加 newProp 或 newProp1 字段,与您的解决方案相同。新房没有出现。
然后我尝试添加姓名、电话或什至 oldProp,一切正常。
功能代码:
@FunctionName("addentity")
public String addentity(@HttpTrigger(name = "req", methods = {"get", "post"}, authLevel = AuthorizationLevel.ANONYMOUS) String req,
ExecutionContext context) {
String storageConnectionString =
"***";
String jsonStr = "insert failed";
try {
// Retrieve storage account from connection-string.
CloudStorageAccount storageAccount =
CloudStorageAccount.parse(storageConnectionString);
// Create the table client.
CloudTableClient tableClient =
storageAccount.createCloudTableClient();
// Create a cloud table object for the table.
CloudTable cloudTable = tableClient.getTableReference("test");
// Create a new customer entity.
myEntity entity = new myEntity("jay1","gong");
//entity.setProp1("a");
entity.setNewProp("new");
entity.setOldProp("old");
//entity.setNewProp1("new1");
//entity.setName("kkkkk");
// Create an operation to add the new customer to the people table.
TableOperation insertEntity =
TableOperation.insert(entity);
// Submit the operation to the table service.
cloudTable.execute(insertEntity);
jsonStr = entity.toString();
} catch (Exception e) {
// Output the stack trace.
e.printStackTrace();
}
return jsonStr;
}
我的实体:
package com.fabrikam.functions;
import com.microsoft.azure.storage.table.TableServiceEntity;
public class myEntity extends TableServiceEntity {
public String m_prop1 = "";
public String m_newProp = "";
public String m_newProp1 = "";
public String name = "";
public String oldProp = "";
public myEntity(String lastName, String firstName) {
this.partitionKey = lastName;
this.rowKey = firstName;
}
public void setProp1(String prop1) {
m_prop1 = prop1;
}
public String getProp1() {
return m_prop1;
}
public String getNewProp(String newProp) {
return m_newProp;
}
public String getNewProp1(String newProp1) {
return m_newProp1;
}
public void setNewProp(String newProp) {
m_newProp = newProp;
}
public void setNewProp1(String newProp1) {
m_newProp1 = newProp1;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getOldProp() {
return oldProp;
}
public void setOldProp(String oldProp) {
this.oldProp = oldProp;
}
}
输出:
我认为'newProp'
Azure 表存储保留了类似的内容,您可以调整名称规则,然后一切都会好起来的。
我做进一步的测试:
只是为了总结,最后,这完全是关于我的 getter 和 setter 的错误格式。我们需要检查对象定义。
添加回答
举报