2017-08-07 71 views
0

使用Azure移動應用程序,我們可以在表格之間進行同步。我正在構建具有不同用途的多個應用。其他應用程序不需要特定表的所有屬性,只需要他需要的一次。是否可以僅從Web API向客戶端返回表的特定屬性?如果這是可能的,那麼我只將屬性推送到客戶端正在使用的Web API。這會影響僅用於這些屬性的表數據嗎?Azure移動應用程序TableController中實體的特定屬性

我已經搜索了類似的網站,但無法找到這樣的: https://shellmonger.com/30-days-of-azure-mobile-apps-the-table-of-contents/ https://adrianhall.github.io/develop-mobile-apps-with-csharp-and-azure/

+0

關於此主題有任何更新?如果有幫助,請將其標記爲有助於解決同一問題的更多社區的答案。 –

回答

0

是否可以從Web API向客戶返回表的只有特定的屬性?

是,Azure的移動應用SDK支持相當多的OData V3規範的,我們可以使用通過使用$select子句選擇特定fiedls。更多細節請參考Data Access Concepts

當我只將屬性推送到客戶端正在使用的Web API。這會影響僅用於這些屬性的表數據嗎?

我們可以做到這一點。根據我的意見,如果我們想要提升所有房產的一部分,那麼我們可能需要包括id fieldversion fieldId字段文件使表實體全局唯一。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(); 
} 
相關問題