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 關注
- 107 瀏覽
添加回答
舉報