我有一個Azure移動易桌Xamarin應用程序,它是一堆列表,提醒我自己。它可以很好地添加,更新和刪除。我希望能夠獲得軟刪除項目的列表,以便我可以取消刪除某些項目,將它們添加回列表中而不用重新輸入它們。我無法弄清楚如何做到這一點。我在Google搜索中看到了IncludeDeleted屬性,但它似乎不適用於我正在使用的IMobileServiceSyncTable表。這是代碼,但它檢索零記錄。如果我在LinqPad 5中運行它,我會得到所有軟刪除的記錄。查詢Azure移動應用程序中的軟刪除記錄簡易表
public async Task<IEnumerable<ListData>> GetDeletedItemsAsync()
{
await InitializeClient();
await SyncItems();
try
{
IEnumerable<ListData> items = await listdata
.Where(listdata => listdata.Deleted == true)
.ToEnumerableAsync();
return new ObservableCollection<ListData>(items);
}
catch (MobileServiceInvalidOperationException msioe)
{
Debug.WriteLine(@"Invalid sync operation: {0}", msioe.Message);
}
catch (Exception e)
{
Debug.WriteLine(@"Sync error: {0}", e.Message);
}
return null;
}
這裏是類:
public class ListData
{
public string id { get; set; }
[JsonProperty(PropertyName = "listname")]
public string ListName { get; set; }
[JsonProperty(PropertyName = "itemdata")]
public string ItemData { get; set; }
[JsonProperty(PropertyName = "itemdetail")]
public string ItemDetail { get; set; }
[JsonProperty(PropertyName = "deleted")]
public Boolean Deleted { get; set; }
// *** Enable Optimistic Concurrency *** //
[Version]
public string Version { get; set; }
}
我缺少什麼?謝謝。
這給出了錯誤,並且_deleted不能用作參數。我開始看到問題是我想要做的事不能用同步表完成,即offline同步。這不是一個真正的問題。我將不得不使用IMobileServiceTable直接從服務器獲取已刪除的項目,然後取消刪除我想要刪除的項目並重新同步已同步的表格以在我的應用程序中查看它們。我是這個應用程序編程的新手,並且會讚賞我在正確軌道上的構造,以及使用IMobileServiceTable對象獲取和更新記錄的一些代碼示例。 –
Robertb