我有一个使用Azure App Service Back End的Xamarin移动应用程序。除非我想添加记录,否则一切似乎都有效。我的课程如下:
> db.col.aggregate(
... [
... {$replaceRoot : {newRoot : "$value"}}
... ]
... )
{ "empId" : "1234", "naSales" : "101000", "euSales" : "102000" }
{ "empId" : "9820", "naSales" : "302000", "euSales" : "200000", "asiaSales" : "230000" }
>
我创建了一个新网站:
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;
应该很简单,但我一直在
请求无法完成。 (错误请求)
我希望有更多信息,以便帮助找出请求不好的原因。有没有人对我如何跟踪这个问题有任何建议?
*更新*
我放了调用堆栈,但是它很长。我删除了它。我发现了问题并将发布答案。
答案 0 :(得分:0)
答案实际上有点令人尴尬。由于一些评论,我研究了在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");
}
}
我忽略了私有变量而不是公共财产。一旦我解决了这个问题,它就很有效!感谢所有帮助过的人。