我一直在研究这个问题一段时间,但无法解决它。任何帮助将非常感激...
使用 Azure 表存储(不是开发存储)我只是想从表中删除一行:
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
Fiddler 没有透露任何有趣的东西。
我没主意了...
再次,任何帮助将不胜感激。
干杯