希望有人可以帮助我,我现在已经和这个问题一起四处走动了,我希望我能错过一些小事。
我在Azure上有一个SQL服务器数据库,它链接到移动同步解决方案。 我使用了快速启动并为TODO获得了后端和移动应用程序等。其中将一个toDOitem表添加到我的数据库中。
现在我正在尝试创建一个控制器等来匹配数据库中的另一个表,使用ToDO作为模板。 当我进行推送时,我没有得到任何错误,但没有添加任何数据,但是当我执行拉动时,它会返回内部错误异常。
控制器
public class InterventionController : TableController<Intervention>
{
protected override void Initialize(HttpControllerContext controllerContext)
{
base.Initialize(controllerContext);
HDTermTypeBETAContext context = new HDTermTypeBETAContext();
DomainManager = new EntityDomainManager<Intervention>(context, Request);
}
// GET tables/TodoItem
public IQueryable<Intervention> GetAllIntervention()
{
var a = Query();
return Query();
}
// GET tables/TodoItem/48D68C86-6EA6-4C25-AA33-223FC9A27959
public SingleResult<Intervention> GetIntervention(string id)
{
return Lookup(id);
}
// PATCH tables/TodoItem/48D68C86-6EA6-4C25-AA33-223FC9A27959
public Task<Intervention> PatchIntervention(string id, Delta<Intervention> patch)
{
return UpdateAsync(id, patch);
}
// POST tables/TodoItem
public async Task<IHttpActionResult> PostIntervention(Intervention item)
{
Intervention current = await InsertAsync(item);
return CreatedAtRoute("Tables", new { id = current.Id }, current);
}
// DELETE tables/TodoItem/48D68C86-6EA6-4C25-AA33-223FC9A27959
public Task DeleteIntervention(string id)
{
return DeleteAsync(id);
}
表对象
哪个与表字段匹配等。
公共课干预:EntityData
{
//public Guid Id { get; set; }
public string InterventionGroupId { get; set; }
public string Prefix { get; set; }
public string ResultId { get; set; }
public string OptionText { get; set; }
public bool SilentTrigger { get; set; }
public bool Active { get; set; }
public Nullable<DateTime> DateDeactivated { get; set; }
public int ProjectId { get; set; }
}
移动推送逻辑
IMobileServiceSyncTable<Intervention> todoTable;
todoTable = client.GetSyncTable<Intervention>();
await todoTable.PullAsync("intervention", todoTable.CreateQuery());
移动表格对象
public class Intervention
{
public string Id { get; set; }
[JsonProperty(PropertyName = "InterventionGroupId")]
public string InterventionGroupId { get; set; }
[JsonProperty(PropertyName = "Prefix")]
public string Prefix { get; set; }
[JsonProperty(PropertyName = "ResultId")]
public string ResultId { get; set; }
[JsonProperty(PropertyName = "OptionText")]
public string OptionText { get; set; }
//[Column(Name = "OptionRequired", DbType = "bit NOT Null", CanBeNull = false)]
//public bool OptionRequired { get; set; }
//[Column(Name = "CommentsRequired", DbType = "bit NOT Null", CanBeNull = false)]
//public bool CommentsRequired { get; set; }
[JsonProperty(PropertyName = "SilentTrigger")]
public bool SilentTrigger { get; set; }
[JsonProperty(PropertyName = "Active")]
public bool Active { get; set; }
[JsonProperty(PropertyName = "DateDeactivated")]
public Nullable<DateTime> DateDeactivated { get; set; }
[JsonProperty(PropertyName = "ProjectId")]
public int ProjectId { get; set; }
}