Returning list owned by multiple entities

0

In my application I have some entities and from some information of each one I need to perform a query in the database and display this information in a grid . I'm working with ASP.Net MVC 4 and my application is divided into layers: VO, BO, DO

I'll try to give a more brief example of the difficulty I'm having. See the entities below:

    class Cliente
{
    public int IdCliente { get; set; }
    public string NomeCliente { get; set; }
}

class Usuario
{
    public int IdUsuario { get; set; }
    public string NomeUsuario { get; set; }
}

class ChamadoTecnicoStatus
{
    public int IdChamadoTecnicoStatus { get; set; }
    public string DescricaoChamadoTecnicoStatus { get; set; }
}

class ChamadoTecnico
{
    public int IdChamadoTecnico { get; set; }
    public DateTime DataChamadoTecnico { get; set; }
    public int IdChamadoTecnicoStatus { get; set; }
    public string InformacaoChamadoTecnico { get; set; }
    public int IdCliente { get; set; }
    public int IdUsuario { get; set; }
}

What I'm going to need is to make a select in the bank and bring the information as below:

IdChamadoTecnico | DataChamadoTecnico | DescricaoChamadoTecnicoStatus | InformacaoChamadoTecnico | NomeCliente | NomeUsuario

I think I could easily solve this if I return to my presentation layer a DataTable but that's exactly what I did not want to do. I wanted my method to return only a List<objeto> but this way I would have to have this entity:

    class EntidadeParaListaDeChamadosTecnicos
{
    public int IdChamadoTecnico { get; set; }
    public DateTime DataChamadoTecnico { get; set; }
    public string DescricaoChamadoTecnicoStatus { get; set; }
    public string InformacaoChamadoTecnico { get; set; }
    public string NomeCliente { get; set; }
    public string NomeUsuario { get; set; }
}

And this I totally believe is not recommended to do.

What is the best practice? I'm looking for some pattern on the internet but by now I did not find anything.

    
asked by anonymous 24.07.2014 / 23:11

1 answer

1

The best way would be to actually create a ModelView (MV) and then your popular Controller the same with the data that will be displayed in your View

    
01.08.2014 / 07:21