是否可以從Web API向客戶返回表的只有特定的屬性?
是,Azure的移動應用SDK支持相當多的OData V3規範的,我們可以使用通過使用$select
子句選擇特定fiedls。更多細節請參考Data Access Concepts。
當我只將屬性推送到客戶端正在使用的Web API。這會影響僅用於這些屬性的表數據嗎?
我們可以做到這一點。根據我的意見,如果我們想要提升所有房產的一部分,那麼我們可能需要包括id field和version field。 Id
字段文件使表實體全局唯一。Version
字段全是關於衝突檢測。
如果有任何衝突,我們可以使用我們的邏輯來處理衝突。更多詳細信息請參考Handling Conflict Resolution。以下是文檔中的演示代碼。
sync Task ResolveConflictAsync(MobileServiceTableOperationError error)
{
var serverItem = error.Result.ToObject<T>();
var localItem = error.Item.ToObject<T>();
// Note that you need to implement the public override Equals(TodoItem item)
// method in the Model for this to work
if (serverItem.Equals(localItem))
{
// Items are the same, so ignore the conflict
await error.CancelAndDiscardItemAsync();
return;
}
// Client Always Wins
localItem.Version = serverItem.Version;
await error.UpdateOperationAsync(JObject.FromObject(localItem));
// Server Always Wins
// await error.CancelAndDiscardItemAsync();
}
關於此主題有任何更新?如果有幫助,請將其標記爲有助於解決同一問題的更多社區的答案。 –