I'm trying to use LINQ
extension methods to query some strongly typed collections in a razor view, powered by RazorEngine. The problem is, it doesn't recognize System.Linq
namespace; @using System.Linq
generates an error in Intellisense:
the type or namespace Linq does not exist in the namespace (are you missing an assembly reference )
I'm looking for a solution without installing WebPages
or MVC
packages.
Things I have already tried (from other answers for related problems around here):
<add key="webpages:Version" value="3.0.0.0" />
to app.config<system.web><compilation debug="false" targetFramework="4.5.2" /></system.web>
to app.configEach of these measure solved some problems: initially Intellisense didn't work at all, now it recognizes the following System
sub-namespaces:
CodeDom, Collections, ComponentModel, Configuration, Data,
Deployment, Diagnostics, Drawning, EnterpriseServices, Globalization, IO, Media, Net, Reflection, Resourcers, Runtime, Security, Text,
Threading, Timers, Web, Windows, Xml
Snippet of my view:
@using RazorEngine.Template
@using System.Linq <!--namespace doesn't exist in System-->
@using Namespace.Of.My.Models
@inherits TemplateBase<ThisPageModel>
<table class="my-table-class">
<thead>
<tr>
<th>Column1</th>
</tr>
<tr>
<th>Column2</th>
</tr>
</thead>
<tbody>
@foreach(var item in Model.Children)
{
<tr>
<td>
@item.ListOfThings.First() <!--List<Things> does not contains a definition for First-->
</td>
</tr>
}
</tbody>
</table>
Simply copy system.core.dll
to the bin directory of your project.
In the past I have also found it necessary to use bin
as my build directory instead of bin\debug
but this appears to no longer be necessary.