Reputation: 4125
I am not sure what went wrong but i could not able top use linq in razor view, but i can use linq in controllers.
for example, i cannot run this code
@foreach (char ch in "abcdefghijklmnopqrstuvwxyz".ToCharArray().Where(ch=>ch!='a'))
{
}
or
@Html.EditorFor(e=>e.Id )
any solution for this?
Update: The problem was that, IDE shows red underline where linq is used. but runs without any problem.
Upvotes: 2
Views: 5344
Reputation: 35409
Add the Linq
namespace in your view:
@using System.Linq
The System.Linq namespace is in the System.Core assembly (in System.Core.dll)
http://msdn.microsoft.com/en-us/library/system.linq.aspx
Upvotes: 3