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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T11:57:22+00:00 2026-06-11T11:57:22+00:00

I have an application with an entity of class A. A has a field

  • 0

I have an application with an entity of class A. A has a field B, which is used by some viewmodels but not all. The field B is loaded in a separate loading operation from a different source.

What layer should be responsible for loading this field B? I see three alternatives:

  1. Implement logic in A to load B whenever it’s accessed. It works, but requires some logic in the A class. I feel that the entity classes should have minimal logic, and certainly not have logic related to loading data from the data source (but I may be wrong).
  2. Let the data access layer (DAL) load B whenever it loads an instance of A. This is not optimal as loading data from the datasource (which is a remote server) is slow, and only a few of the instances of A requires the field B.
  3. Let the viewmodel load B using the DAL if it needs it. This seems to me (a guy relatively unexperienced in the ways of MVVM) to be the most “MVVM-y” way of doing this.

#3 seems less “elegant” compared to #1 when it comes to the “it just works”-factor (with #1, accessing the field B would automatically load it from the datasource). But #3 seems to separate the concerns in a better way, as the entity objects is not given the responsibility of loading more data.

  • 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-06-11T11:57:24+00:00Added an answer on June 11, 2026 at 11:57 am

    Go for #3.

    Entity models, which in a case of a client app should be data transfer object, should not have any logic at all. This will (most probably) save a lot of time when you will try to write unit tests or/and chage the dto’s.

    I would simply inject a dependency into each view model representing master item, and then allow it to get it data. This will also allow to rather simply notify user with a busy indicator thorugh IsBusy property on the item view model.

    You can also imlement a separate Command class which will handle download task, but it will require some upper level services to notify user with in process operation, but this is the cleanest aproach I can imagine.

    So start with 3, and if logic to download child will grow reasonably enough to incapsulate it in a command class, just do it. But try to avoid static implamantations by all costs.

    Sorry for a bad grammar.

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

Sidebar

Related Questions

I have an entity which has an ID field: @Id @Column(name = `U##ID_VOIE`) @GeneratedValue(generator
I have a code first application which defined like this: public abstract class Entity
I have an entity class in my Enterprise Java application that has an entity
I have an ASP.NET Dynamic Data application (using Entity Framework) in which I have
In my java application, I have some entity, some of them may have the
I have a User entity that has a Current Location field (city and country).
I have a .NET 3.5 web application which has a set of classes handling
i have made an application having entity framewrok. It is wpf application, now it
I have created a new application using Entity Framework 4.3 database migrations. The migrations
I have asp.net application and am using Entity Framework to connect it with the

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.