@if ( Model.Select(p=>p.Payments.Any(o=>o.Expires>DateTime.Now))!= null)
{
<table class="table">
<tr>
<th>
@Html.DisplayName("Student ID")
</th>
<th>
@Html.DisplayName("Full Name")
</th>
<th>
@Html.DisplayName("Expiry Date")
</th>
<th>
@Html.DisplayName("Contact Number")
</th>
<th></th>
@foreach (var item in Model.Where(p => p.Payments.Any(o => o.Expires > DateTime.Now)))
{
<tr>
<td>
@Html.DisplayFor(modelItem => item.StudentID)
这是MVC项目中的首页,我想显示已过期的学生。我使用了If
语句,但不知道为什么会出现异常。