private IQueryable <Customer> ApplyFilters(IQueryable <Customer> efQuery, GetCustomerOrders request)
 {
     if (!string.IsNullOrWhiteSpace(request.NameSearch))
     {
         efQuery = efQuery.Where(c => c.CompanyName.Contains(request.NameSearch));
     }
     return(efQuery);
 }
 private IQueryable <Customer> ApplyPaging(IQueryable <Customer> efQuery, GetCustomerOrders request)
 {
     if (request.PageIndex.HasValue && request.PageSize.HasValue)
     {
         return(efQuery
                .Skip(request.PageIndex.Value * request.PageSize.Value)
                .Take(request.PageSize.Value)
                .OrderBy(c => c.CompanyName));
     }
     return(efQuery);
 }
        public async Task <IEnumerable <CustomerOrdersModel> > Handle(GetCustomerOrders request, CancellationToken cancellationToken)
        {
            var efQuery = _context.Set <Customer>().Where(c => true);

            efQuery = ApplyFilters(efQuery, request);
            efQuery = ApplyPaging(efQuery, request);

            return(await SimpleSelect(efQuery));

            // return await ToListSelect(efQuery);
            // return await SelectAnon(efQuery);
            // return await ReusableProjection(efQuery);
            // return await ExtensionMethod(efQuery);
            // return await AutoMapper(efQuery);


            // Note: Show Linqkit predicate builder
            // http://www.albahari.com/nutshell/predicatebuilder.aspx
        }