我需要在silverlight,asp.net等表示層,所以一切都是通過wcf服務。 我在實現庫層,服務層的疑惑數量,WCF服務WCF倉庫服務模式與實體框架
事情我目前做
- 我有倉庫,它不是每個表的每一聚集根目錄中創建
- 我有做一組涉及多個資源庫行動服務層的
- WCF服務包
- 的實體由EF 自動生成的業務層和庫層的方法
- 的實體傳遞和返回到服務層爲完整的圖形
6.我有所有的庫包括兩個具體類,服務稱爲repositorycontainer和服務容器,倉庫容器被傳遞給服務
我的倉庫基地
public class RepositoryBase
{
public DataBaseContext _Context;
public RepositoryContainer _RepositoryContainer;
public RepositoryBase(RepositoryContainer repositoryContainer)
{
_RepositoryContainer = repositoryContainer;
_Context = repositoryContainer.Context;
}
public RepositoryBase()
{
_RepositoryContainer = new RepositoryContainer();
_Context = _RepositoryContainer.Context;
}
}
我的倉庫容器
public class RepositoryContainer
{
public RepositoryContainer()
{
Context = new DataBaseContext();
}
public RepositoryContainer(DataBaseContext context)
{
Context = context;
}
public DataBaseContext Context
{
get;
set;
}
public SurveyRepository _SurveyRepository;
public SurveyRepository SurveyRepository
{
get
{
return _SurveyRepository ?? (_SurveyRepository = new SurveyRepository(this));
}
}
}
我的服務容器
public class ServiceContainer
{
public ServiceContainer()
{
RepositoryContainer = new RepositoryContainer();
}
public ServiceContainer(RepositoryContainer container)
{
RepositoryContainer = container;
}
public RepositoryContainer RepositoryContainer
{
get;
set;
}
public SurveyService _SurveyService;
public SurveyService SurveyService
{
get
{
return _SurveyService?? (_SurveyService= new SurveyService(this));
}
}
}
做一次手術 我只是創建RepositoryContainer或的ServiceContainer
然後調用
RepositoryContainer.Repository.Method()
ServiceContainer.Service.Method()
我的疑惑是
是該服務/儲存容器罰款?
我已經有服務層,所以我有wcf服務什麼我叫當前服務層servicewrapper什麼的?我需要調用存儲庫方法本身,例如:GetCategory()等,也是服務層中的所有方法,所以我需要在wcf服務中包裝方法和服務,這很好嗎?
在哪裏做緩存?因爲我使用EF我覺得有什麼辦法使用與EF緩存提供商,
- 客戶可以直接訪問各個WCF方法,或通過服務層(其中「集合」的一個或多個WCF方法到一個更大/更復雜的「法」 - 是正確的 - 緩存:是否如果是這樣 - 在哪裏? - ServiceContainer和RepositoryContainer之間的區別是什麼? – 2010-07-25 02:08:18
存儲庫像GetCategories,Insert Delete等一樣,操作/ BL在服務中完成,例如:我有用戶存儲庫,測量存儲庫,當我更新調查時,我更新了用戶(邏輯)中的一個字段,因此它在調查服務中處理,它調用用戶和調查庫方法, 只是我的存儲庫沒有將conatin邏輯,所有的邏輯包裝到服務層,而不是創建每個存儲庫實例,它全部包裝到存儲容器中,所以我只需要創建存儲容器(創建它的一個實例並不昂貴), – 2010-07-25 04:43:10
同樣的服務方式,當創建 服務容器存儲庫容器被傳遞時,它隨後傳遞給每個服務實例,因此在每個服務中不需要創建每個存儲庫實例的每個 注意:somhow我不是IoC粉絲。問題是,我喜歡當前沒有WCF的東西,意味着所有的東西都駐留在一臺服務器上,我需要單獨的apllication服務器(BL),如果它的全部在一起,我只需引用核心dll,創建存儲庫容器實例,服務容器調用方法,現在我需要WCF – 2010-07-25 04:43:28