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

  • SEARCH
  • Home
  • 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 6124371
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T16:07:31+00:00 2026-05-23T16:07:31+00:00

I’m working on a web application project using ASP.NET MVC3 and database in SQL

  • 0

I’m working on a web application project using ASP.NET MVC3 and database in SQL Server. There is also a mobile application that uses the data from the same database via REST services. Here are some of my application’s layers:

  • Model – ADO.NET Data Model, using Entity Framework

  • Data Access Layer – Repositories with queries to retrive data from database

  • Web application – MVC3 project, using repositories, loose coupling using Structure Map and DI, database context gets disposed at the end of the HttpRequest

  • Core – another layer between DAL and Service Layer, uses Repositories and exposes data to Service Layer. Sort of Business Logic Layer.

  • Service Layer – REST services, knows about Core layer but not about DAL. Maps the data to DTOs and exposes to the client

The problem I’ve got with such application architecture is loose coupling on the Service Layer. Service Layer has reference to Core layer. Core layer has reference to Data Access Layer and uses its repositories. Repositories do not have a default constructor though. They expect 1 parameter and its database object context (disposable object).

Using repositories directly on my website is not a problem. I’m using Structure Map and DI makes it loosely coupled. Each context gets disposed at the end of the HttpRequest.

The problem is that Service Layer and Core layer. I’d like to have loose coupling there as well but not sure how to achieve it? How to inject data context into those and make sure it gets disposed at certain moment? I’d like to hear some suggestions on how to put it all together.

  • 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-23T16:07:32+00:00Added an answer on May 23, 2026 at 4:07 pm

    Service Layer has reference to Core layer.

    That’s fine.

    Core layer has reference to Data Access Layer and uses its repositories.

    That ain’t fine.

    Your “Core” should be your domain, with business rules and logic. It should not have any dependencies.

    Start from the bottom of the stack:

    1. Repo – no dependencies on other layers.
    2. Services – dependency on Core and Repo.
    3. Core – no dependencies on other layers.
    4. Web – dependant on everything.

    This is how we do it. We use a combination of interface-driven programming and dependency injection to handle the loose coupling.

    Example flow:

    1. HTTP Request comes in (API, web tier, etc)
    2. Controller found. DI container sees container has dependancy on ISomethingService and resolves it, including any further down dependencies (service, repo, etc).
    3. Controller calls method on ISomethingService.
    4. ISomethingService implementation (chosen by DI) calls method on ISomeRepo.
    5. ISomeRepo implementation (chosen by DI) calls EF/DB, returns “data-object” to service.
    6. Service maps “data-object” to “Core” object and returns to controller.

    The instantiation of these objects should be handled by your DI container. The only thing missing from the above which we use is a “Unit of Work”, which essentially wraps the EF context.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

That's pretty much it. I'm using Nokogiri to scrape a web page what has
link Im having trouble converting the html entites into html characters, (&# 8217;) i
Seemingly simple, but I cannot find anything relevant on the web. What is the
I'm making a simple page using Google Maps API 3. My first. One marker
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
We're building an app, our first using Rails 3, and we're having to build
We are using XSLT to translate a RIXML file to XML. Our RIXML contains
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and
I want use html5's new tag to play a wav file (currently only supported
Does anyone know how can I replace this 2 symbol below from the string

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.