概述:在 CompletedQuestions 表中,UserId 对应于完成该问题的用户。Id 属性对应于 Questions 表中的问题之一。我知道,我没有正确指定关系。但我不是很有经验。我只想完成一个项目,然后我会在了解更多信息后回来修复那些糟糕的编码实践。我无法理解以下异常。
LINQ to Entities does not recognize the method 'Riddle.Models.CompletedQuestion LastOrDefault[CompletedQuestion](System.Linq.IQueryable`1[Riddle.Models.CompletedQuestion])' method, and this method cannot be translated into a store expression.
Line 46: if (RiddleCompleted == null)
Line 47: {
Line 48: var lastCompletedQuestion = _db.CompletedQuestions.Where(q => q.UserId == currentUserId) // exception occurs in this line
Line 49: .OrderBy(q => q.QuestionNumber)
Line 50: .LastOrDefault();
Run Code Online (Sandbox Code Playgroud)
发生异常的动作:
public ActionResult Riddle(int Id)
{
string currentUserId = User.Identity.GetUserId();
var riddle = _db.Riddles.Where(r => r.Id == Id).Single();
if …Run Code Online (Sandbox Code Playgroud) 为什么不允许这样做:
<style src="someCssFile.css"></style>
Run Code Online (Sandbox Code Playgroud)
而这是允许的:
<script src="someJsFile.js"></script>
Run Code Online (Sandbox Code Playgroud)
我不明白为什么我必须对 css 文件使用链接标记。我认为使用样式标签更有意义。