【发布时间】:2015-10-29 07:21:08
【问题描述】:
我正在尝试了解如何在 Azure 移动应用中使用 TableController。这是示例TodoItemController:
public class TodoItemController : TableController<TodoItem>
{
protected override void Initialize(HttpControllerContext controllerContext)
{
base.Initialize(controllerContext);
MobileServiceContext context = new MobileServiceContext();
DomainManager = new EntityDomainManager<TodoItem>(context, Request, Services);
}
// GET tables/TodoItem
public IQueryable<TodoItem> GetAllTodoItems()
{
return Query();
}
// GET tables/TodoItem/48D68C86-6EA6-4C25-AA33-223FC9A27959
public SingleResult<TodoItem> GetTodoItem(string id)
{
return Lookup(id);
}
// PATCH tables/TodoItem/48D68C86-6EA6-4C25-AA33-223FC9A27959
public Task<TodoItem> PatchTodoItem(string id, Delta<TodoItem> patch)
{
return UpdateAsync(id, patch);
}
// POST tables/TodoItem
public async Task<IHttpActionResult> PostTodoItem(TodoItem item)
{
TodoItem current = await InsertAsync(item);
return CreatedAtRoute("Tables", new { id = current.Id }, current);
}
// DELETE tables/TodoItem/48D68C86-6EA6-4C25-AA33-223FC9A27959
public Task DeleteTodoItem(string id)
{
return DeleteAsync(id);
}
}
- 理想情况下,我希望避免传递像
TodoItem这样的整个模型,以减少传入/传出带宽并将客户端限制在他们应该关心的范围内。如果我这样做,离线同步和客户端 SDK 会受到怎样的影响? -
TableController是否用于上述建议的简单 CRUD 操作?网上有什么复杂查询的例子吗?
【问题讨论】:
-
客户端用什么? Windows商店应用程序?移动应用 ?据我所知,azure sqlitestore 将始终推/拉整个实体
标签: rest azure azure-mobile-services