使用Linq Any()时MVC Razor语法错误

时间:2019-03-07 17:30:13

标签: asp.net-mvc linq razor

自升级到最新版本的VS2017以来,我遇到了一个奇怪的问题;在我在ViewModel的列表上使用.Any()的任何MVC视图中,都会显示错误:

The type 'ValueType' is defined in an assembly that is not referenced. You must add a reference to assembly 'System.Runtime, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'.

但是,在运行该应用程序时似乎没有引起任何问题,并且一切正常,我只是对为什么显示此错误感到困惑。

以下是我遇到问题的代码段,该错误在Model.BreakInLearnings.Any()行下突出显示:

<div class="col-sm-6">
    @Html.LabelFor(m => m.StatusChangeReason, "Comment")
    @Html.TextAreaFor(m => m.StatusChangeReason, new { @rows = "4", @style = "resize: none", @class = "form-control" })
    @if (Model.BreakInLearnings.Any())
    {
        <label>Test BILs: @(Model.BreakInLearnings.Count) total.</label>
    }
</div>

0 个答案:

没有答案