"One of the query input errors failed" when trying to update the Azure table storage

I am trying to update an entry in Azure table storage. Function:

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

If this is a new entry (path "bug.RowKey == null"), then it works fine. If it is updating an existing object, then “AttachTo” and “UpdateObject” will work, but when it goes to “SaveChanges”, it will throw an exception “One of the request inputs is invalid”.

Persistent class:

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

Does anyone know what the problem is?

Thanks for any help.

+4
source share
2 answers

In case someone is looking for an answer:

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


Working in the context of a table, I had to change the call:

 _context.AttachTo(c_TableName, bug); 

in

 _context.AttachTo(c_TableName, bug, "*"); 
+6
source

You can also get this error if you mistakenly set the RowKey to the value you already used (not that you will get this problem with the code in the question). I tried to click 50+ objects at a time and accidentally set the RowKey to the same value for two objects.

+2
source

Source: https://habr.com/ru/post/1306481/


All Articles