I'm trying to return a JSON with a nested list using Navigation properties but I keep getting null in the 'Usuario' collection here's the output.
[
{
"$id": "1",
"id": 1,
"encabezado": "Como llamar a un metodo en c#",
"cuerpo": "Estoy intentando llamar un metodo metodo() pero no puedo alguna sugerencia xD?",
"points": 0,
"Usuario": null,
"Respuestas": []
},
{
"$id": "2",
"id": 2,
"encabezado": "Como cambiar conection String",
"cuerpo": "Es posible cambiar el conection string en asp.net si ya esta creada?",
"points": 1,
"Usuario": null,
"Respuestas": []
}
]
here's my .edmx
And finally this is where I have the web api
namespace AskTecProject.Controllers
{
public class QuestionController : ApiController
{
[HttpGet]
public List<Pregunta> GetQuestions()
{
using (asktecdbEntities entities = new asktecdbEntities())
{
List<Pregunta> p = entities.Usuarios.Where(m => m.id.Equals(1)).SelectMany(m => m.Preguntas).ToList<Pregunta>();
return p;
}
}
}
}
I got his query from Getting a related collection but I'm still having trouble with this, I'll appreciate any help
