/// <summary> /// Returns an enumerable collection of products. /// </summary> /// <param name="filter">Repository filter.</param> /// <param name="classNames">Class names of products to retrieve.</param> public IEnumerable <SKUTreeNode> GetProducts(IRepositoryFilter filter, params string[] classNames) { return(pageRetriever.Retrieve <TreeNode>( query => query .WhereIn("ClassName", classNames) .Where(filter?.GetWhereCondition()) .WhereTrue("SKUEnabled") .FilterDuplicates(), cache => cache .Key($"{nameof(ProductRepository)}|{nameof(GetProducts)}|{filter?.GetCacheKey()}|{string.Join(";", classNames)}") .Dependencies((_, builder) => builder.ObjectType("ecommerce.sku"))) .Select(page => page as SKUTreeNode)); }
/// <summary> /// Returns an enumerable collection of brewers ordered by the date of publication. /// </summary> /// <param name="filter">Repository filter.</param> /// <param name="count">The number of brewers to return. Use 0 as value to return all records.</param> public IEnumerable <Brewer> GetBrewers(IRepositoryFilter filter, int count = 0) { return(pageRetriever.Retrieve <Brewer>( query => query .TopN(count) .WhereTrue("SKUEnabled") .Where(filter?.GetWhereCondition()) .FilterDuplicates() .OrderByDescending("SKUInStoreFrom"), cache => cache .Key($"{nameof(BrewerRepository)}|{nameof(GetBrewers)}|{filter?.GetCacheKey()}|{count}") // Include dependency on all pages of this type to flush cache when a new page is created. .Dependencies((_, builder) => builder.Pages(Brewer.CLASS_NAME).ObjectType("ecommerce.sku")))); }