2012-06-22 153 views
0

我有兩個上下文提供者的實現,我知道還會有更多的關注。 我想創建接口來爲通用的實體工作。實體框架上下文的接口

public class TDataProvider 
    { 
     public TEntities GetDataContext() 
     { 
      return new TTEntities(); 
     } 
    } 

public class TDataProvider 
    { 
     public TEntities GetDataContext() 
     { 
      return new TTEntities(); 
     } 
    } 

我想使用在每一種情況下,如 但我怎麼實現了通過ADO.NET實體數據模型生成實體模型跟隨着inteface mplemeneted接口?

public class IGetDataContext 
    { 
     T GetDataContext(); 
    } 
+0

數據上下文是依賴項,所以使用IoC容器而不是接口。 –

回答

0

而不是創建針對上我已經創建了負責行爲的數據訪問類上下文接口和創建單元測試。

它是我能想到的最好的。