I'm trying out the Razor ViewEngine from ASP.NET MVC 3 Preview 1 and I'm running into an issue trying to using the Any()
extension method.
Here's the code I use to set the property in the controller:
ViewModel.Comparisons = DB.Comparisons.Where(c => c.UserID == this.UserID).ToArray();
Here's the code in the View where I try to use Any()
:
@if (!View.Comparisons.Any()) {
<tr>
<td>You haven't not started any comparisons yet. @Html.Action("Start a new comparison?", "create", "compare")</td>
</tr>
}
I get an exception that says:
'System.Array' does not contain a definition for 'Any'
I've tried adding the System.Linq
namespace to both the pages\namespaces
section of web.config, and adding a @using System.Linq
line at the top of the view, neither of which made a difference. What do I need to do to have access to the LINQ extension methods?
Update: It looks like it has to do with the fact that it's a property of a dynamic object - it works if I manually cast it to IList<T>
.