0
我一直在這個問題上工作了一段時間,只是無法繞過它。任何幫助,將不勝感激......Azure存儲表 - 刪除項目錯誤
使用Azure Table中存儲(不開發存儲),我只是想從一個表中刪除行:
Public Sub DeleteByItemId(pairItemId As String)
Dim item = (From c In _ServiceContext.UserTable Where c.Id = pairItemId Select c).Single()
_ServiceContext.DeleteObject(item)
_ServiceContext.SaveChanges()
End Sub
這將導致一個錯誤:「上下文目前沒有跟蹤實體。「
而這種做法:
Public Sub DeleteByItemId(itemId As String)
Dim item = New <object type>
item.PartitionKey = "sandbox"
item.RowKey = itemId
_ServiceContext.AttachTo(<table name>, item, "*")
_ServiceContext.DeleteObject(item)
_ServiceContext.SaveChanges()
End Sub
錯誤與此:
<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<error xmlns="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata">
<code>InvalidInput</code>
<message xml:lang="en-US">One of the request inputs is not valid.
RequestId:e37b0824-3336-4089-b6ac-2824438618f6
Time:2012-08-07T01:37:28.2741813Z</message>
</error>
如何服務上下文被創建:
Public Sub New()
Dim storageAccount = CloudStorageAccount.FromConfigurationSetting("DataConnectionString")
_ServiceContext = New OroosoUserPairedAccountDataServiceContext(storageAccount.TableEndpoint.ToString(), storageAccount.Credentials)
_ServiceContext.IgnoreResourceNotFoundException = True
_ServiceContext.MergeOption = MergeOption.NoTracking
' Create the tables
' In this case, just a single table.
storageAccount.CreateCloudTableClient().CreateTableIfNotExist(<table name>)
End Sub
提琴手沒有透露什麼有趣的事。
我沒有想法...
再次,任何幫助將不勝感激。
乾杯
有人編輯我的問題,把它變成一個答案,這是一個很好的提醒,它*實際上是一個問題。我將它作爲註釋移動到此處:您是否嘗試刪除'_ServiceContext.MergeOption = MergeOption.NoTracking'? – smarx 2012-08-07 03:37:29
這工作。不知道該行最初來自哪裏。你爲什麼不把這個答案放在一個答案中,以便我可以將其標記爲... – 2012-08-07 16:39:06