0
I am created to action of Edit to edit my data models. What happens is I use Viewmodel to "join" several models in a.
Okay, I can get the data from models who are not List<>, that is, the models that are not a list. My case is that I have lists and needed to get all the records relating to id that I’m signing at Action so that the data can be loaded on the screen, and edit that data.
The code I have is this one:
CliCliente cliente = db.CliCliente.Find(id);
Tabela2 tabela2 = db.Tabela2.Find(id);
Tabela3 tabela3 = db.Tabela3.Find(id);
List<Tabela4> tabela4 = db.Tabela4.ToList<Tabela4>();
In which List<Tabela4> tabela4 = db.Tabela4.ToList<Tabela4>(); returns all the data, because I don’t have a criterion to return only what is related in id that I’m bringing into the action.
How could I do to scan and bring the specific list data related to id sent in the signature of action?
If the
idis ofCliClienteandTabela2,Tabela3andTabela4are related, why don’t you just select fromCliClienteand uses onlyInclude()s to load the aggregated data?– Leonel Sanches da Silva
I tried, but I couldn’t... And that way with include would come out a list? Because I need to return a list...
– Érik Thiago
Return to where?
– Leonel Sanches da Silva
for the view... And also in the controller
– Érik Thiago