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