コード例 #1
0
ファイル: DatabaseDataPager.cs プロジェクト: alexis-/Sidekick
        /// <summary>Loads data for given page.</summary>
        /// <param name="start">Start item index.</param>
        /// <param name="size">Page size.</param>
        /// <returns></returns>
        public async Task <IEnumerable <T> > LoadPageAsync(int start, int size)
        {
            // Create base query
            ITableQueryAsync <T> baseQuery = _db.Table <T>();

            if (_queryFunc != null)
            {
                baseQuery = _queryFunc(baseQuery);
            }

            ITableQueryAsync <T> fetchQuery = baseQuery.Skip(start).Take(size);

            return(await fetchQuery.ToListAsync().ConfigureAwait(false));
        }
コード例 #2
0
        /// <summary>
        ///   Update page item according to current page.
        /// </summary>
        /// <returns></returns>
        public override async Task UpdateCurrentPageItemsAsync()
        {
            // Create base query
            ITableQueryAsync <T> baseQuery = _db.Table <T>();

            if (_queryFunc != null)
            {
                baseQuery = _queryFunc(baseQuery);
            }


            // Count items
            _itemCount = await baseQuery.CountAsync().ConfigureAwait(false);


            // Fetch and add items
            int skip = (CurrentPage - 1) * PageSize;
            ITableQueryAsync <T> fetchQuery = baseQuery.Skip(skip).Take(PageSize);

            IEnumerable <T> newItems = await fetchQuery.ToListAsync().ConfigureAwait(false);

            using (CurrentPageItems.SuspendChangeNotifications())
                ((ICollection <T>)CurrentPageItems).ReplaceRange(newItems);
        }