我试图更新Azure Table中存储的条目。该函数是:

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; }
}

有谁知道问题是什么?

感谢您的帮助。

有帮助吗?

解决方案

在任何人的情况下是需要的答案:

HTTP:// social.msdn.microsoft.com/Forums/en-US/windowsazure/thread/0c9d476e-7970-422a-8b34-e987e41734df


工作在表方面,我不得不呼叫从改变:

_context.AttachTo(c_TableName, bug); 

为:

_context.AttachTo(c_TableName, bug, "*"); 

其他提示

您也可以得到这个错误,如果您错误地设置RowKey你已经使用的值(不是说你会得到这个问题的问题代码)。我试图推动50个+实体一气呵成,不小心有RowKey设置为同一个值,两个实体。

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top