2 回答
TA贡献1777条经验 获得超3个赞
你已经在你的问题中说过你有业务逻辑层。那是管理这些东西的最佳场所。
因此,您不会在另一个存储库中调用一个存储库。相反,您可以通过 BLL 的一种方法调用两个存储库来实现目标。希望您的 UoW 暴露于 BLL。这样,在相同的 UoW 范围内,您可以执行这两个操作。
这不仅限于Get记录。这可以进一步扩展到Get- Modify-Update或其他任何内容。
我不确定你是做什么的CheckSomeCondition。它只是一个 Predicate 就可以了。如果它是某些业务逻辑的一部分,更好的方法是如上所述将其转移到 BLL。
TA贡献1884条经验 获得超4个赞
最直接的方法是在其构造函数ProductCategoryRepository中创建一个实例:ProductSubcategoryRepository
public class ProductCategoryRepository : Repository<ProductCategory>, IProductCategoryRepository
{
private ProductSubcategoryRepository subRepo;
public ProductCategoryRepository(DbContext context) : base(context)
{
subRepo = new ProductSubcategoryRepository(context);
}
public IEnumerable<ProductCategory> GetProductCategoriesBeforeDate()
{
// call subRepo
}
}
如果你已经有一个ProductSubcategoryRepository你可以注入它的实例:
public ProductCategoryRepository(DbContext context, ProductSubcategoryRepository subRepo) : base(context)
{
this.subRepo = subRepo;
}
- 2 回答
- 0 关注
- 170 浏览
添加回答
举报
