public void DeleteProducts(List <string> produList) { PerformDeleteObjects <Product>(produList, _productRepository, id => { var categorization = _productCategorizationRepository.GetBySpecification(Specification <ProductCategorization> .Eval(c => c.ProductId == id)); if (categorization != null) { _productCategorizationRepository.Remove(categorization); } }); }
// 将指定的商品从其所属的商品分类中移除 public void Uncategorize(Product product, Category category = null) { Expression <Func <ProductCategorization, bool> > specExpress = null ; if (category == null) { specExpress = p => p.ProductId == product.Id; } else { specExpress = p => p.ProductId == product.Id && p.CategoryId == category.Id; } var productCategorization = _productCategorizationRepository.GetByExpression(specExpress); if (productCategorization == null) { return; } _productCategorizationRepository.Remove(productCategorization); _repositoryContext.Commit(); }