0
假设我有以下POCO实体:单位 - 计算性能
public class SomeEntity
{
public int SomeProperty { get; set; }
}
及以下系统信息库
public class SomeEntityRepository
{
Context _context;
public SomeEntityRepository(Context context)
{
_context = context;
}
public List<SomeEntity> GetCrazyEntities()
{
return _context.SomeEntities.Where(se => se.SomeProperty > 500).ToList();
}
}
然后由于某种原因,我要实现对计算性能SomeEntity like:
class SomeEntity
{
...
public List<SomeEntity> WellIDependOnMyOnRepositry()
{
...
return theRepository.GetCrazyEntities().Where(se => se.SomeProperty < 505).ToList();
}
}
我该如何处理POCO实体意识到回购使用适当的UnitOfWork实现的itory/context?
我一直在寻找IoC和依赖注入,但我有点太愚蠢,无法理解它的蝙蝠。
一些启示?
那么..什么是可以让你想要在你的Entity中引用仓库的“某种原因”?现在,WellIDependOnMyRepository方法看起来像属于SomeEntityRepository,而不是SomeEntity – surfen 2012-03-30 21:42:40
是的,这个例子并没有反映我所遇到的真正问题,而是我急于离开工作。你是对的。当我回家时,我会用更准确的代码编辑我的问题,因为我确信它会导致我获得更好的答案。 – 2012-03-30 22:13:03