1 回答

TA貢獻(xiàn)1786條經(jīng)驗(yàn) 獲得超11個(gè)贊
根據(jù)我的測(cè)試,我認(rèn)為這是因?yàn)槊Q(chēng)規(guī)則。我測(cè)試了添加 newProp 或 newProp1 字段,與您的解決方案相同。新房沒(méi)有出現(xiàn)。
然后我嘗試添加姓名、電話(huà)或什至 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;
}
我的實(shí)體:
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;
}
}
輸出:
我認(rèn)為'newProp'
Azure 表存儲(chǔ)保留了類(lèi)似的內(nèi)容,您可以調(diào)整名稱(chēng)規(guī)則,然后一切都會(huì)好起來(lái)的。
我做進(jìn)一步的測(cè)試:
只是為了總結(jié),最后,這完全是關(guān)于我的 getter 和 setter 的錯(cuò)誤格式。我們需要檢查對(duì)象定義。
添加回答
舉報(bào)