2
I have two tables: Pessoa
and Catequizando
, with a 1:1 ratio and want to make a "Get" to the data of the two tables, both "id s" are equal, so I did the
Catequizando catequizando = db.Catequizando.Find(id);
Pessoa pessoa = db.Pessoa.Find(id);
I don’t know how to do the return view
of the 2 tables.
Controller:
public ActionResult Edit(int? id)
{
if (id == null)
{
return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
}
Catequizando catequizando = db.Catequizando.Find(id);
Pessoa pessoa = db.Pessoa.Find(id);
if (catequizando == null)
{
return HttpNotFound();
}
ViewBag.CatequizandoID = new SelectList(db.Pessoa, "PessoaID", "Nome", catequizando.CatequizandoID);
return View(catequizando);
}
Unfortunately you didn’t answer my question, I can do @create between 2 models in the view, using a viewmodel, but I can’t "get" the data from 2 tables in Edit.
– Simão Lopes
I think I got it, your problem is in . Find(id) ? because in the question you put "I don’t know how to do the 2 tables' view." ?
– Brunno
@Brunno Why did you erase your answer?
– Leonel Sanches da Silva
@I think I ran away from what he was asking
– Brunno
@Brunno did not run away no. This is the right way. Only a few things are missing.
– Leonel Sanches da Silva