public async Task <PageResult <OrderItem> > GetOrderItemsAsync(PageRequest <OrderItem> request)
        {
            // Where
            IQueryable <OrderItem> items = _dataSource.OrderItems;

            if (request.Where != null)
            {
                items = items.Where(request.Where);
            }

            // Query
            // Not supported
            //if (!String.IsNullOrEmpty(request.Query))
            //{
            //    items = items.Where(r => r.SearchTerms.Contains(request.Query));
            //}

            // Count
            int count = items.Count();

            if (count > 0)
            {
                int pageSize = Math.Min(count, request.PageSize);
                int index    = Math.Min(Math.Max(0, count - 1) / pageSize, request.PageIndex);

                // Order By
                if (request.OrderBy != null)
                {
                    items = items.OrderBy(request.OrderBy);
                }
                if (request.OrderByDesc != null)
                {
                    items = items.OrderByDescending(request.OrderByDesc);
                }

                // Execute
                var records = await items.Skip(index *pageSize).Take(pageSize)
                              .Include(r => r.Product)
                              .AsNoTracking().ToListAsync();

                return(new PageResult <OrderItem>(index, pageSize, count, records));
            }
            return(PageResult <OrderItem> .Empty());
        }
        public async Task<PageResult<Customer>> GetCustomersAsync(PageRequest<Customer> request)
        {
            // Where
            IQueryable<Customer> items = _dataSource.Customers;
            if (request.Where != null)
            {
                items = items.Where(request.Where);
            }

            // Query
            if (!String.IsNullOrEmpty(request.Query))
            {
                items = items.Where(r => r.SearchTerms.Contains(request.Query.ToLower()));
            }

            // Count
            int count = items.Count();
            if (count > 0)
            {
                int pageSize = Math.Min(count, request.PageSize);
                int index = Math.Min(Math.Max(0, count - 1) / pageSize, request.PageIndex);

                // Order By
                if (request.OrderBy != null)
                {
                    items = items.OrderBy(request.OrderBy);
                }
                if (request.OrderByDesc != null)
                {
                    items = items.OrderByDescending(request.OrderByDesc);
                }

                // Execute
                var records = await items.Skip(index * pageSize).Take(pageSize)
                    .Select(r => new Customer
                    {
                        CustomerID = r.CustomerID,
                        Title = r.Title,
                        FirstName = r.FirstName,
                        MiddleName = r.MiddleName,
                        LastName = r.LastName,
                        Suffix = r.Suffix,
                        Gender = r.Gender,
                        EmailAddress = r.EmailAddress,
                        AddressLine1 = r.AddressLine1,
                        AddressLine2 = r.AddressLine2,
                        City = r.City,
                        Region = r.Region,
                        CountryCode = r.CountryCode,
                        PostalCode = r.PostalCode,
                        Phone = r.Phone,
                        CreatedOn = r.CreatedOn,
                        LastModifiedOn = r.LastModifiedOn,
                        Thumbnail = r.Thumbnail
                    })
                    .AsNoTracking()
                    .ToListAsync();

                return new PageResult<Customer>(index, pageSize, count, records);
            }
            return PageResult<Customer>.Empty();
        }