Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

205
Views
MVVM - How to handle anonymous types composed of models inside ViewModel

Currently my view has the need to receive a List containing information from two different models.

Something like this

public class ViewModel
{
    [JsonProperty("")]
    public List<Unknown> viewModelList;
}

This Unknown type would have information from two different models, like so.

public class FirstModel
{
    int w;
    int x;
}

public class SecondModel
{
    int y;
    int z;
}

public class Unknown //Model or ViewModel?
{
    [JsonProperty("")]
    int w; //From FirstModel

    [JsonProperty("")]
    int x; //From SecondModel
}

My question is, this Unknown type would have to be a Model? My idea of a Model is that they represent Business entities or Database entities, and ViewModel are abstractions of those models. In this case, Unknown is nothing, but an abstraction of both FirstModel and SecondModel, so I think it characterizes more as a ViewModel, than a Model, but then if I treat it as a ViewModel, I'm unable to make a List out of it, because otherwise my code would be as follows

public class ViewModel
{
    [JsonProperty("")]
    public List<UnknownViewModel> viewModelList;
}

It would be a ViewModel inside a ViewModel, and I don't know if this is common or good practice.

over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

There's absolutely no functional difference in what you call it. What matters is how you use the types.

A model is simply a type that contains data (or state). And a view-model, as its name suggests, is the model used as the backing for a view (or presentation). That's all.

Here, in your example, you're using Unknown as a model -- one that's being used as the element type of a collection property of a type that will presumably be used as a view-model.

over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!