我有一个问题,那就是“品类类”包含了很多产品类。但是现在,我有一个 CategoryService 类,它将在相同的情况下实现 find IList 每个类别只包含前 n 个产品,而不是所有产品,我该怎么办?给我一个选择,谢谢!
代码清单:
public class category
{
public int Id{get;set;}
public int Categoryname{get;set;}
public IList<Product> Products{get;set;}
}
public class Product
{
public int Id{get;set;}
public string ProductName{get;set;}
public Category Category{get;set;}
etc...
}
然后有一个域服务:
public class CategoryService
{
private ICategoryRepository categoryRepository;
public CategoryService(ICategoryRepository categoryRepository)
{
this.categoryRepository=categoryRepository;
}
public IList<Category> FindAll()
{
IList<Category> categories;
categories=categoryRepository.FindAll();
//and now i need categoryRepository find all category ,and every category contains top n product, what should i do;
return categories;
}
}