我在这里变得非常绝望,因为在我遇到一些不幸的 git 问题并且不得不清除我的项目并再次结帐之前,这段代码正在运行。由于某种原因,我的 IQueryable 对象不再允许我引用属性。在我下面的代码中,evt.id 应该是有效的,但 id 在 Visual Studio 中不被识别为 evt 的属性。另外,我应该提一下,我不仅无法访问 evt,而且也无法访问属于目标的任何属性。重新编码控制器的这一部分时我错过了什么?
public HttpResponseMessage GetTodaysPatientGoals(int id)
{
var evt = db.patient_event.Where(e => (e.patient_id == id) && (e.date == DateTime.Today));
//evt.id is not recognized here either
if(evt != null)
{
//evt.id is not recognized as a property of evt here
//also cant access properties of goal either
var goal = db.patient_goals.Where(g => (g.patient_id == id) && (g.event_id == evt.id)).Select(row => (new { row.id, row.completed, row.goal }));
return Request.CreateResponse(HttpStatusCode.OK, goal);
}
return Request.CreateResponse(HttpStatusCode.NoContent);
}
任何帮助将不胜感激。