Azure SDK 删除异步请求内容 null

本文关键字:null 请求 异步 SDK 删除 Azure | 更新日期: 2023-09-27 18:35:59

我有一个带有 .NET 后端的 Azure 移动服务,但无法删除记录。当我调试到 Delete 函数时,该项目为空。当我打电话给这个时。请求 在即时窗口中,我得到底部返回的字符串。我曾经使用节点js后端,但已切换到.NET后端,因此客户端代码没有更改。

复习项目类:

public class ReviewItem
{
    public string Id { get; set; }
    public string Line1 { get; set; }
    public string Line2 { get; set; }
    public string Line3 { get; set; }
    public string Line4 { get; set; }
    public System.DateTime LastUpdated { get; set; }
}  

客户端:

var dbReviewItems = await reviewTable.ToListAsync();
foreach (var item in dbReviewItems)
    await reviewTable.DeleteAsync(item);

服务器端:

public void Delete(T item)
{
    Context.Delete(item.Id);
    Context.SaveChanges();
}

上下文:

// passing in Id because passing the item caused a not found exception
public T Delete(string Id) 
{
    var item = Find(Id);
    if (item == null) return null;
    return Context.Set<T>().Remove(item);
}

控制器的请求(在 Azure 服务器上以调试模式运行,从 wp 模拟器调用):

{Method: DELETE, RequestUri: 'https://xxxx.azure-mobile.net/tables/ReviewItem/016f5328-c6fa-4b14-9c41-73976a0afda8', Version: 1.1, Content: System.Net.Http.StreamContent, Headers:  
{  
  Cache-Control: no-cache  
  Connection: Keep-Alive  
  Accept: application/json  
  Accept-Encoding: gzip  
  Host: xxxx.azure-mobile.net  
  Max-Forwards: 10  
  User-Agent: ZUMO/1.3  
  User-Agent: (lang=Managed; os=Windows Phone; os_version=8.10.0.12358; arch=Win32NT; version=1.3.21121.0)  
  X-ZUMO-FEATURES: TT  
  X-ZUMO-INSTALLATION-ID: xxxx  
  X-ZUMO-APPLICATION: xxxx  
  X-ZUMO-AUTH: xxxx  
  X-ZUMO-VERSION: ZUMO/1.3 (lang=Managed; os=Windows Phone; os_version=8.10.0.12358; arch=Win32NT; version=1.3.21121.0)  
  X-LiveUpgrade: 1  
  X-ARR-LOG-ID: xxxx  
  DISGUISED-HOST: xxxx.azure-mobile.net  
  X-SITE-DEPLOYMENT-ID: xxxx  
  X-Original-URL: /tables/ReviewItem/016f5328-c6fa-4b14-9c41-73976a0afda8  
  X-Forwarded-For: 70.186.182.236:4945  
  X-ARR-SSL: 2048|128|DC=com, DC=microsoft, DC=corp, DC=redmond, CN=MSIT Machine Auth CA 2|C=US, S=WA, L=Redmond, O=Microsoft, OU=OrganizationName, CN=*.azurewebsites.net  
  Content-Length: 0  
}}  
    Content: {System.Net.Http.StreamContent}  
    Headers: {Cache-Control: no-cache  
Connection: Keep-Alive  
Accept: application/json  
Accept-Encoding: gzip  
Host: xxxx.azure-mobile.net  
Max-Forwards: 10  
User-Agent: ZUMO/1.3 (lang=Managed; os=Windows Phone; os_version=8.10.0.12358; arch=Win32NT; version=1.3.21121.0)  
X-ZUMO-FEATURES: TT  
X-ZUMO-INSTALLATION-ID: xxxx  
X-ZUMO-APPLICATION: xxxx  
X-ZUMO-AUTH: xxxx  
X-ZUMO-VERSION: ZUMO/1.3 (lang=Managed; os=Windows Phone; os_version=8.10.0.12358; arch=Win32NT; version=1.3.21121.0)  
X-LiveUpgrade: 1  
X-ARR-LOG-ID: a252fe87-03c9-487a-87c8-aa454c906f79  
DISGUISED-HOST: xxxx.azure-mobile.net  
X-SITE-DEPLOYMENT-ID: xxxx  
X-Original-URL: /tables/ReviewItem/016f5328-c6fa-4b14-9c41-73976a0afda8  
X-Forwarded-For: 70.186.182.236:4945  
X-ARR-SSL: 2048|128|DC=com, DC=microsoft, DC=corp, DC=redmond, CN=MSIT Machine Auth CA 2|C=US, S=WA, L=Redmond, O=Microsoft, OU=OrganizationName, CN=*.azurewebsites.net  
}  
    Method: {DELETE}  
    Properties: Count = 11  
    RequestUri: {https://xxxx.azure-mobile.net/tables/ReviewItem/016f5328-c6fa-4b14-9c41-73976a0afda8}  
    Version: {1.1}

Azure SDK 删除异步请求内容 null

我是个哑巴。我使控制器的删除方法接收一个对象。它应该接收一个字符串 ID。