在View中使用System.Linq

时间:2016-03-02 07:47:01

标签: asp.net-mvc-4 view

我有一个db结构如下

FeedbackTable      
   Id
   Name
   ...
   ...

ProjectApprovalTable
    Id
    FeedbackId
    ...
    ...

我正在将FeedbackDetails传递给视图。如何在视图中访问projectapproval details

这就是我试过的

 if (Model.StudentFeedback[i].IsTrainerVerified == true && Model.StudentFeedback[i].StudentProjectApprovals.FirstOrDefault().IsTrainerApproved == false)
 {
  ...
 }

我收到错误No Extension Method for FirstOrDefault()

模型类

 public partial class StudentFeedback
{
    public StudentFeedback()
    {
        this.StudentProjectApprovals = new HashSet<StudentProjectApproval>();
    }

    public int Id { get; set; }
    ....
    ....
    public virtual ICollection<StudentProjectApproval> StudentProjectApprovals { get; set; }
}

0 个答案:

没有答案