【发布时间】:2016-12-06 17:02:57
【问题描述】:
我正在尝试使用导航属性返回带有嵌套列表的 JSON,但我在“Usuario”集合中一直为空,这是输出。
[
{
"$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": []
}
]
这是我的 .edmx
最后这就是我拥有 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;
}
}
}
}
我从 Getting a related collection 收到了他的问题,但我仍然遇到问题,我将不胜感激
【问题讨论】:
标签: json asp.net-mvc entity-framework asp.net-web-api ado.net