public IList <ProductListModel> GetProductListModels(ProductListOptionsModel options) { using (var context = _contextFactory.CreateContext()) { return(context.ProductBases .AsNoTracking() .FilterBy(options) .OrderBy(p => p.ProductBaseCode) .ProjectBetween <ProductBase, ProductListModel>() .ToList()); } }
public static IQueryable <ProductBase> FilterBy(this IQueryable <ProductBase> productBases, ProductListOptionsModel options) { Expression <Func <ProductBase, bool> > filter = pb => (options.BusinessLineId == null || pb.BusinessLineId == options.BusinessLineId) && (options.ProductStatusId == null || pb.ProductStatusId == options.ProductStatusId) && (options.ProductSourceTypeId == null || pb.ProductSourceTypeId == options.ProductSourceTypeId) && (options.ProductDestinationTypeId == null || pb.ProductDestinationTypeId == options.ProductDestinationTypeId) && (options.ProductMaterialId == null || pb.ProductMaterialId == options.ProductMaterialId) && (options.ProductTypeId == null || pb.ProductTypeId == options.ProductTypeId) && (options.ProductGroupId == null || pb.ProductGroupId == options.ProductGroupId) && (options.ProductBrandId == null || pb.ProductBrandId == options.ProductBrandId) && (options.ProductCollectionId == null || pb.ProductCollectionId == options.ProductCollectionId) && (options.ProductDesignId == null || pb.ProductDesignId == options.ProductDesignId); return(productBases.Where(filter)); }
private void InitializeOptionsModel() { OptionsModel = _service.GetProductListOptionsModel(); OptionsModel.OptionChanged += ClearItems; }