Azure 移动后端无法添加记录

Azure Mobile Back End Can't add records

我有一个使用 Azure 应用服务后端的 Xamarin 移动应用。一切似乎都正常,除非我想添加记录。我的class如下:

public partial class Site : INotifyPropertyChanged
{

    public Site()
    {
        SiteMarks = new ObservableCollection<SiteMark>();
        DelSiteMarks = new ObservableCollection<SiteMark>();
    }


    public event PropertyChangedEventHandler PropertyChanged;

    protected void RaisePropertyChanged(string propertyName)
    {
        PropertyChangedEventHandler propertyChanged = this.PropertyChanged;
        if ((propertyChanged != null))
        {
            propertyChanged(this, new PropertyChangedEventArgs(propertyName));
        }
    }

    [JsonProperty(PropertyName = "Id")]
    public string Id { get; set; }

    [JsonProperty(PropertyName = "Name")]
    public string Name { get; set; }

    [JsonProperty(PropertyName = "SiteID")]
    public string SiteID { get; set; }

    [JsonProperty(PropertyName = "Address")]
    public string Address { get; set; }

    [JsonProperty(PropertyName = "Note")]
    public string Note { get; set; }

    [JsonProperty(PropertyName = "Icon")]
    public string Icon { get; set; }

    [JsonProperty(PropertyName = "Lat")]
    public double? Lat { get; set; }

    [JsonProperty(PropertyName = "Lng")]
    public double? Lng { get; set; }

    [JsonIgnore]
    private string _MarkerID;
    public string MarkerID
    {
        get
        {
            return _MarkerID;
        }
        set
        {
            _MarkerID = value;
            RaisePropertyChanged("MarkerID");
        }
    }

    [JsonIgnore]
    public ObservableCollection<SiteMark> SiteMarks { get; set; }

    [JsonIgnore]
    public ObservableCollection<SiteMark> DelSiteMarks { get; set; }

}

我是这样创建一个新站点的:

Site site = new Site();
site.SiteMarks = new System.Collections.ObjectModel.ObservableCollection<SiteMark>();
site.Id = Guid.NewGuid().ToString("N");
site.SiteID = SiteID;
site.Name = Name;
site.Address = Address;
site.Lat = Lat;
site.Lng = Lng;

那我就打电话:

await SiteTable.UpdateAsync(site);

应该很简单,但我不断得到

The request could not be completed. (Bad Request)

我希望有更多信息,以便帮助找出请求错误的原因。有人对我如何追踪它有什么建议吗?

*更新*

我已经放置了调用堆栈,但它太长了。我已经删除了它。我发现了问题并会 post 一个答案。

这个回答其实有点尴尬。由于一些评论,我研究了在 Azure 上调试实际服务 运行。当我从中获得调试跟踪时,我发现它无法找到 MarkerID。所以它的瘦身是:

[JsonIgnore]
private string _MarkerID;
public string MarkerID
{
    get
    {
        return _MarkerID;
    }
    set
    {
        _MarkerID = value;
        RaisePropertyChanged("MarkerID");
    }
}

确实需要

private string _MarkerID;
[JsonIgnore]
public string MarkerID
{
    get
    {
        return _MarkerID;
    }
    set
    {
        _MarkerID = value;
        RaisePropertyChanged("MarkerID");
    }
}

我忽略了私有变量而不是 public 属性。一旦我解决了这个问题,它就很好用!感谢所有帮助过的人。