Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 946561
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T22:56:16+00:00 2026-05-15T22:56:16+00:00

I need presentation layer in silverlight, asp.net etc , so everything is through wcf

  • 0

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

things i currently do

  1. I have repository , its not per table its created per aggregate root
  2. I have service layer its for doing a group of actions involving multiple repository
  3. WCF service wraps the methods in service layer and repository layer
  4. The entities are auto generated by EF
  5. The entities are passed and returned to service layer as complete graph

6.I have two concrete class with all repository , and service called repositorycontainer and service container , Repository container is passed to the service

My repository base

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;
        }


    }

My repository container

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));
            }           
        }


}

My service container

 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));
            }           
        }


    }

To do an operation
I just create RepositoryContainer or ServiceContainer

then calls

RepositoryContainer.Repository.Method()
ServiceContainer.Service.Method()

My doubts are

  1. Is that service / respository container fine ?

  2. I already have the service layer, so as i have wcf service what i call the current service layer servicewrapper or something ?

  3. 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 ?

  4. Where to do the caching ? as i am using EF i think there is something way to use a cache provider with EF ,

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-15T22:56:16+00:00Added an answer on May 15, 2026 at 10:56 pm

    Is that service / respository
    container fine ?

    The RepositoryContainer class contains a “SurveyRepository” – but shouldn’t the SurveyRepository be an instance of a RepositoryContainer? Same for ServiceContainer and “SurveyService”. It would make more sense to me if they were (although it’s hard to comment accurately without being more familiar with the project).

    You’d then have: ServiceContainer SurveyService = new ServiceContainer(..);

    As you have it, I get the impression that “SurveyService” is a specific business concept but it’s wrapped up in a more generic type (ServiceContainer); same for SurveyRepository / RepositoryContainer.

    This will break SRP, Common Closure Principle and probably Common Reuse Principle.

    I’m not sure what other think, but I’m also not a fan of naming instances after their types (except in the most basic of senarios – which this isn’t): public SurveyRepository SurveyRepository The name of the type should reflect what the type is (or does) which will be quiote different from a specific instance of it (like ServerContainer and ServeyService).

    I already have the service layer, so
    as i have wcf service what i call the
    current service layer servicewrapper
    or something ?

    and

    So i need to change name of my service
    (BL) layer to something service
    wrapper or something , then in wcf
    service layer i define methods in
    repository and service then just calls
    curresponding methods in service,
    repository

    Generally any reusable BL should be in a standalone package and not enclosed (think “hard-coded”) in a service layer or WCF service, etc. You’d then create service end-points that sat on top of the BL. If you have business transactions that span different business objects within different packages then you’ll need to put that higher level orchestration somewhere higher – I guess this could go in the service layer, but this isn’t a trival thing to do, you’ll need to carefully consider where certain responsibilities lie.

    If the transaction scover different business objects within the same package then the orchestration is much simpler and can be done with another BL type designed to handle that job, which will be part of that package – and not in the service layer.

    Regarding the naming – go to a whiteboard and map everything out, and then rename everything as required. At least with a single cohesive overview you’ll be able to make clear sense of everything.

    BL packages should be named as appropriate to what they do – in business terms. WCF services that wrap these should have a name that fits and this could include reference to the type of channel being used (JSON, WebService, etc). Because you can change the channel a WCF service uses by config (if the service is design correctly) this might not be a good idea – but assuming it doesn’t then the extra clarity might be helpful.

    These articles might be of help:

    • http://blogs.oracle.com/christomkins/2009/07/my_thoughts_on_service_naming.html
    • http://ea.typepad.com/enterprise_abstraction/2006/08/service_naming_.html
    • What naming convention do you use for the service layer in a Spring MVC application?

    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 ?

    Wrapping a service in a service sounds a bit suspect. Only external callers should go through the services – assuming the services are designed to expose the BL to external parties. Internal callers should know which is the appropriate method to call (by virtue of being internal), presumably it’s the same method that is exposed by the service.

    Where to do the caching ? as i am
    using EF i think there is something
    way to use a cache provider with EF

    I don’t know if you can cache in EF4 but it wouldn’t surprise me if you can. Where to do caching? – it depends on where the bottle kneck is that you’re trying to eliminate.

    In your RepositoryContainer, the _SurveyRepository field is public – shouldn’t it be private? Otherwise why have a read-only (get) SurveyService property?

    public SurveyRepository _SurveyRepository;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to path information from BL layer to the presentation layer via WCF
I've been asked to go through an existing ASP.NET application and Document the logic
I have a three layered Java application consisting of a presentation layer, a business
I have a full Java EE web application with a presentation layer and a
I am an asp.net web application developer and I always have used Enterprise Library
i build a small application with asp.net mvc framework. I have one question. I
My basic ASP.NET structure is always 3 projects DAL = Data accesses layer -
I am developing an ASP.NET 2.0 website. I have created data access and business
I have four project apart from Presentation layer Business Logic Layer Interface layer Object
Suppose you have a layered project divided into the Presentation Layer, the Business Layer

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.