Note that there are some explanatory texts on larger screens.

plurals
  1. POWCF Repository Service pattern with entity framework
    text
    copied!<p>I need presentation layer in silverlight, asp.net etc , so everything is through wcf services. I have number of doubts in my implementation of repository layer, service layer, wcf services</p> <p>things i currently do</p> <ol> <li>I have repository , its not per table its created per aggregate root</li> <li>I have service layer its for doing a group of actions involving multiple repository</li> <li>WCF service wraps the methods in service layer and repository layer</li> <li>The entities are auto generated by EF </li> <li>The entities are passed and returned to service layer as complete graph</li> </ol> <p>6.I have two concrete class with all repository , and service called repositorycontainer and service container , Repository container is passed to the service </p> <p>My repository base </p> <pre><code>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; } } </code></pre> <p>My repository container</p> <pre><code>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)); } } } </code></pre> <p>My service container</p> <pre><code> 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)); } } } </code></pre> <p>To do an operation I just create RepositoryContainer or ServiceContainer</p> <p>then calls</p> <pre><code>RepositoryContainer.Repository.Method() ServiceContainer.Service.Method() </code></pre> <p>My doubts are</p> <ol> <li><p>Is that service / respository container fine ?</p></li> <li><p>I already have the service layer, so as i have wcf service what i call the current service layer servicewrapper or something ?</p></li> <li><p>I need to call repository methods itself eg: GetCategory() etc , also all methods in service layer, So i need to wrap both methods and service in wcf service, is it fine ?</p></li> <li><p>Where to do the caching ? as i am using EF i think there is something way to use a cache provider with EF ,</p></li> </ol>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload