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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T03:08:19+00:00 2026-05-23T03:08:19+00:00

The repository pattern seems to work well when working with an initial project with

  • 0

The repository pattern seems to work well when working with an initial project with several large main tables.

However as the project grows it seems a little inflexible. Say you have lots of child tables that hang off the main table, do you need a repository for each table?

E.g.

CustomerAddress Record has following child tables:

-> County

-> Country

-> CustomerType

On the UI, 3 dropdown lists need to be displayed, but it gets a bit tedious writing a repository for each of the above tables which selects the data for the dropdowns.

Is there a best practice/more efficient way of doing this?

As an example say you have a main CustomerAddress repository which I guess is the ‘aggregate root’ which inherits the main CRUD operations from the base repo interface.

Previously I have short-cutted the aggregate root and gone straight to the context for these kinds of tables.

e.g.

public Customer GetCustomerById(int id)
{
  return Get(id);
}

public IEnumerable<Country> GetCountries()
{
  return _ctx.DataContext.Countries.ToList();
}

etc…

But sometimes it doesn’t feel right, as countries aren’t part of the customer, but I feel like I need to tack it onto something without having to create zillions of repos for each table. A repo per table definately doesn’t seem right to me either.

  • 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-23T03:08:20+00:00Added an answer on May 23, 2026 at 3:08 am

    I’m answering my own question here because while the suggestions are certainly useful, I feel I have a better solution.
    While I don’t have to phsyically create the underlying repository for each and every table as I have a generic repository base class with interface (Get, Add, Remove), I still have to:

    1) write the interface to access any specialised methods (generally these are queries)

    2) write those implementations

    I don’t necessarily want to do this when all I want to retrieve is a list of countries or some simple type for populating a dropdown. Think of effort required if you have 10 reference type tables.

    What I decided to do was create a new class called SimpleRepo with ISimpleRepo interface which exposes 1-2 methods. While I don’t normally like to expose the IQueryable interface out of the repo i/f class, I don’t mind here as I want the provided flexibility. I can simply expose a ‘Query()’ method which provides the flexibility hook. I might need this for specialising the ordering, or filtering.

    Whenever a service needs to make use of some simple data, the ISimple< T > interface is passed in, where T is the table/class.

    I now avoid the need to create an interface/class for these simple pieces of data.
    Thoughts anyone?

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

Sidebar

Related Questions

I use the repository pattern for pretty much all of my projects. I have
i wish to create a repository pattern but with a WCF Rest Service which
I know there are a lot of threads here already on the repository pattern
I have the following virtuslhost for my subversion repository and i want to create
I have seen samples for Mercurial ignore files for Visual Studio , amongst others.
Here's the scenario: ASP.NET MVC2 Web Application Entity Framework 4 (Pure POCO's, Custom Data
I am trying to convert this code in my DI mapping from Unity to
I'm dealing with a design problem that I'm sure has a simple answer and/or
I'm porting an existing system to ASP.NET MVC2. In the current legacy app, the
I have the understanding that using data access routines directly from presentation code is

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.