我需要在silverlight,asp.net等中使用表示层,所以一切都是通过wcf服务。 我对存储库层,服务层,wcf服务的实现有很多疑问
我目前正在做的事情
6.我有两个具有所有存储库的具体类,以及名为repositorycontainer和service container的服务,将存储库容器传递给服务
我的存储库
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的缓存提供程序,
答案 0 :(得分:3)