Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

203
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda