public virtual void SearchProducts() { if (AllProducts == null) { if (Repository == null) { throw new ApplicationException("Must set the Repository property."); } else { // Get data from Repository AllProducts = Repository.Search(SearchEntity).OrderBy(p => p.Name).ToList(); } } // Get data for the Products collection if (SearchEntity == null) { Products = AllProducts.ToList(); } else { Products = AllProducts.Where(p => (SearchEntity.Name == null || p.Name.StartsWith(SearchEntity.Name)) && p.ListPrice >= SearchEntity.ListPrice).ToList(); } }
public List <Product> GetAllProducts(bool slow) { //fake a long running query if (slow) { Task.Delay(2000).Wait(); } return(AllProducts.ToList()); }