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

The Archive Base Latest Questions

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

What do you do if you need to generate a read-only list of data

  • 0

What do you do if you need to generate a read-only list of data on a page and that data would naturally come from several, potentially 5 or more different repositories?

We’re using DDD and have been forcing access to our database through repositories, but there is a scenario that has come up that doesn’t seem to fit DDD and we’re trying to decide on the best pattern to use.

For example, let’s say that you have a community based web site with videos, forums, blogs, etc. You’ve got a forums page with a list of comments. This is rough, but I hope it makes sense.

<table>
<tr><td>User Name (with possible link)</td><td>User's community score.</td><td>User Avatar</td><td>User's E-mail</td><td>User's blog</td><td>User's videos</td></tr>
</table>
<table>
<tr><td>This is a comment.</td></tr>
</table>

So each comment contains several different pieces: a user Name, a community score, an avatar, an e-mail, a user’s blog and a user’s video page. Traditionally, these pieces of information would all come from separate repositories.

The issue with that is efficiency. Repositories can be maximized, but only around the aggregate for which their created. Using repositories becomes inefficient for read access the moment that you need access to data that lies in more than one repository.

My solution is to create a UserInformation DTO with the relevant information and place a method in the UserForumsRepository with the signature

ILIst<UserInformation> GetUserForumsUserInformationByForumPostID(int forumPostID).

One of my colleagues suggests that using a DTO in this way breaks the design pattern that we’ve been using and suggests that a better way would be to get a list of forum comment ids and then pass those ids into the various repositories to return the results.

My own view is that main purpose of repositories is to encapsulate business logic which is important for the CUD parts of CRUD, but that read-only lists should be generated in the way that makes most sense. If appropriate, I think that it even makes sense to remove the read-only list methods from the repository entirely (e.g. such as in a common widget that’s used across multiple different types pages).

How do you handle this situation?

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

    Answer #2

    What’s needed here is an extra service layer between the concrete repository and the client. Sometimes, what the client needs is different from what the repository layer provides, especially in the case where the repositories may be distributed. A service layer allows you to define coarsely grained methods and hide the finely grained details from the client. With a services layer, you’re then passing lightweight DTOs on to the client, instead of full fledged business objects.

    To map the business objects to DTOs and the reverse, the tool Automapper is becoming quite popular.

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

Sidebar

Related Questions

I need to generate thumbnails from a set of jpg's that need to have
I'm writing a C# application that needs to generate an HTML page. Only parts
I need to write a small application to read a configuration file and generate
I need to generate some passwords, I want to avoid characters that can be
I have a list of files, which need to be read, in chunks, into
I have a class that defines a read-only property that effectively exposes a private
I need generate thumbnails for a bunch of jpegs (200,000+) but I want to
I need generate action links outside controllers. I can use Html.Action in Views, Url.Action
I need to generate a random number/string to append to a URL to prevent
I need to generate 1D barcode image and set it to ImageView according to

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.