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.