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 6724939
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T09:44:53+00:00 2026-05-26T09:44:53+00:00

I have my entities such as Customer, Order etc. defined in my Domain Model.

  • 0

I have my entities such as Customer, Order etc. defined in my Domain Model.

Now I want to define an interface called IRepository to represent my persistence layer, i will further have SQLRepository, CacheRepository which implement IRepository.

Now i’m wondering if I should define IRepository in the Domain Model or the Data Access Layer? I guess SQLRepository and CacheRepository needs to go in the DAL, but does IRepository go in there too?

Further, for example my Repository returns a list of Customers from the Customer table, i’m a bit confused about how to design this, it seems like i end up repeating types in DAL and Domain Model. See example below:

In the application i want to do something like this :

var repository = new SQLRepository();

//Below repository.customers represents customer table
List<Customer> customers = repository.Customers.list();

So In my Domain:

class Customer
{
  public int id;
  public string name;
}

In my DAL:

class SqlRepository:IRepository
{
   public CustomerTable Customers;
}

class CustomerTable 
{
   public List<Customer> list();
}

I wanted to know if there’s a better way to design these layers?

* UPDATE

I already have the DAL and the Domain defined in different class libraries/assemblies. Initially i thought i will have POCO entities like Customer which represent one record in the database table, but then where do declare Customer.Add(customer) ? does it go in DAL ? I don’t want business rules in DAL, if i start adding methods in my Entities they become complex having persistance logic as well as business logic in them.

  • 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-26T09:44:53+00:00Added an answer on May 26, 2026 at 9:44 am

    The following information is for another problem it shows you a simple project structure: Placing Model in separate assembly

    My opinion is that the IRepository interface should be public in your DataLayer project. The implementations can be private (use a Factory or Dependency Injection to load them in other projects) and the Domain Model you create can be shared by your Business Layer and Data Layer.

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

Sidebar

Related Questions

Assume I have a such model: class Entity(models.Model): start_time = models.DateTimeField() I want to
I have entity e.g. Product which aggregates other entities such as Category . Those
If I have an entity such as the following: @Entity public class Customer {
I have such doctrine entities: <?php namespace App\Entity; use Doctrine\Common\Collections\ArrayCollection; /** * @Entity(repositoryClass=App\Repository\Page) *
I have two entities: patient and checkpoint. Patient has attributes such as DOB, name,
I have an object that I want to be constructed in such manner: var
I have updated my model in Datastore so now it has an additional field.
In Domain Driven Design are collection properties of entities allowed to have partial values?
I want to have a read-only functionality in one of my entities. I know
I am developing an piece of software where I have a few entities such

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.