更新时间:2022-02-10 14:50:32
的优点;组合性:
的缺点;非可测性:
有关稳定,我已经采取为不可以暴露的IQueryable< T>
或防爆pression< ...>
在我的仓库。这意味着,我知道如何存储库的行为,我的上层可以使用模拟考试,无需担心与实际存储库支持呢? (强制集成测试)。
For stability, I've taken to not exposing IQueryable<T>
or Expression<...>
on my repositories. This means I know how the repository behaves, and my upper layers can use mocks without worrying "does the actual repository support this?" (forcing integration tests).
我仍然可以使用的IQueryable&LT; T&GT;
等的在的资源库 - 但不超过边界。我发布了一些更多的心思在这里。这也很容易把页面参数库接口。您甚至可以使用扩展方法(界面)来添加的选的页面参数,使混凝土类只有1个的方法来实现,但有可能是2或3重载提供给调用者。
I still use IQueryable<T>
etc inside the repository - but not over the boundary. I posted some more thoughts on this theme here. It is just as easy to put paging parameters on the repository interface. You can even use extension methods (on the interface) to add optional paging parameters, so that the concrete classes only have 1 method to implement, but there may be 2 or 3 overloads available to the caller.