/// <summary> /// Evaluate the query and repopulate our collection with the results. /// </summary> private async void EvaluateQueryAsync() { // Invoke the query on the server and get our data TotalCountEnumerable <T> data = await MobileServiceTable <T> .EvaluateQueryAsync <T>(this.table, this.query) as TotalCountEnumerable <T>; // Reset the collection with the new data this.data.Clear(); this.data.AddRange(data); this.totalCount = data.TotalCount; this.OnCollectionChanged( new NotifyCollectionChangedEventArgs( NotifyCollectionChangedAction.Reset)); }
/// <summary> /// Evaluates the query and adds the result to the collection. /// </summary> /// <param name="token">A token to cancel the operation.</param> /// <param name="query">The query to evaluate.</param> /// <returns>A task representing the ongoing operation.</returns> protected async virtual Task <int> ProcessQueryAsync(CancellationToken token, IMobileServiceTableQuery <TTable> query) { // Invoke the query on the server and get our data TotalCountEnumerable <TTable> data = await query.ToEnumerableAsync() as TotalCountEnumerable <TTable>; //check for cancellation if (token.IsCancellationRequested) { throw new OperationCanceledException(); } foreach (var item in this.PrepareDataForCollection(data)) { this.Add(item); } this.TotalCount = data.TotalCount; return(data.Count()); }