【发布时间】:2017-05-03 04:21:44
【问题描述】:
我想从ShowById 显示下面Show 方法的结果,但我得到InvalidOperationException: The view 'ShowById' was not found
public async Task<IActionResult> ShowById(int id)
{
Expression<Func<Question, bool>> findById = (q) => q.QuestionId == id;
return await this.Show(findById);
}
private async Task<IActionResult> Show(
Expression<Func<Question, bool>> predExp)
{
var question = await _context.Questions
.Where(predExp)
.FirstOrDefaultAsync();
if (question == null) {
return NotFound();
}
question.Topics = await (
from topic in _context.Topics
join qtopic in _context.QuestionTopics on topic.TopicId equals qtopic.TopicId
where qtopic.QuestionId == question.QuestionId
select topic
).ToListAsync();
question.Answers = await _context.Answers
.Where(a => a.QuestionId == question.QuestionId)
.ToListAsync();
return View(question);
}
【问题讨论】:
标签: asp.net-core asp.net-core-mvc