In this my question Doubt GET WebApi I face some error due to relationships . But now taking it as a basis on account of my models, how could I consume this service? Because the Table1 model has relationships and I needed to bring them to the MVC I'm using to consume ... But what happens is that relationships, models, are not filled, come null ...
My controller in ASP.NET MVC:
public ActionResult Index()
{
//Varialvel resposável por receber os dados que estão no banco de dados para mostrar na tela
HttpResponseMessage resposta = cliente.GetAsync("http://meuservico/api/servico").Result;
//Se der tudo certo, é porque trouxe os dados retornando código 200
if (resposta.IsSuccessStatusCode)
{
//Formata o json para mostrar na tela
var result = resposta.Content.ReadAsAsync<IEnumerable<Tabela1>>().Result;
//retorna para a tela os json formatado
return View(result);
}
//Caso tenha dado errado, retorna somente a tela sem dado algum
return View();
}
The variable result brings the model Table1 prequel, but your relationships do not ... What could be happening?