我总是使用Repository模式但是对于我的最新项目,我想看看我是否可以完善它的使用和我的"工作单元"的实现.我开始挖的越多,我开始问自己一个问题:"我真的需要它吗?"
现在这一切都从Stackoverflow上的一些评论开始,跟踪Ayende Rahien在他的博客上的帖子,其中有2个具体,
这可能是永远和永远讨论的,它取决于不同的应用程序.我想知道什么
使用扩展方法很容易做到这一点.干净,简单,可重复使用.
public static IEnumerable GetAll(
this ISession instance, Expression<Func<T, bool>> where) where T : class
{
return instance.QueryOver().Where(where).List();
}
Run Code Online (Sandbox Code Playgroud)
使用这种方法和NinjectDI,我是否需要创建Context一个接口并将其注入我的控制器?
architecture aop design-patterns entity-framework repository-pattern