我正在尝试更新 Azure 表存储中的条目。其功能是:
public void SaveBug(DaBug bug)
{
bug.PartitionKey = "bugs";
bug.Timestamp = DateTime.UtcNow;
if (bug.RowKey == null || bug.RowKey == string.Empty)
{
bug.RowKey = Guid.NewGuid().ToString();
_context.AddObject(c_TableName, bug);
}
else
{
_context.AttachTo(c_TableName, bug);
_context.UpdateObject(bug);
}
_context.SaveChanges();
}
如果它是一个新条目(“bug.RowKey == null”路径),那么它工作正常。如果是对现有实体的更新,则“AttachTo”和“UpdateObject”调用可以工作,但是当它到达“SaveChanges”时,它会抛出“请求输入之一无效”异常。
正在存储的类是:
[DataContract]
[DataServiceKey("RowKey")]
public class DaBug
{
[DataMember]
public bool IsOpen { get; set; }
[DataMember]
public string Title { get; set; }
[DataMember]
public string Description { get; set; }
[DataMember]
public string SubmittedBy { get; set; }
[DataMember]
public DateTime SubmittedDate { get; set; }
[DataMember]
public string RowKey { get; set; }
public DateTime Timestamp { get; set; }
public string PartitionKey { get; set; }
}
有人知道问题出在哪里吗?
感谢您的帮助。
最佳答案
如果有人正在寻找答案:
<小时/>通过表上下文,我必须更改调用:
_context.AttachTo(c_TableName, bug);
至:
_context.AttachTo(c_TableName, bug, "*");
关于azure - 尝试更新 Azure 表存储时出现 "One of the request inputs not valid"错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2608044/