toddams / RazorLight

Template engine based on Microsoft's Razor parsing engine for .NET Core
Apache License 2.0
1.51k stars 261 forks source link

Adding @inherits... causes linq statements to choke #363

Closed tpspencer closed 4 years ago

tpspencer commented 4 years ago

I have moved all of my views to a class lib project. Everything works fine. I started adding these two statements to the top of each view to gain Intellisense back.

`@using RazorLight

@inherits TemplatePage ` Now I get Intellisense in my views, but Linq statements do not work. I even tried adding a using statement for System.Linq, but that did not help.

Here is the top of the view.

` @model IEnumerable @using RazorLight @inherits TemplatePage @using System.Linq

@{ var cabTypes = Model.Select(x => x.CABType).Distinct().OrderBy(x => x); } `

Here is the error.

Failed to compile generated Razor template:

OS: Windows 10 Platform: .NET Core 3.1 RazorLight 2.0.0-beta9 Visual Studio version: Visual Studio Community 2019 16.6.5

tpspencer commented 4 years ago

Turns out I was passing in an IEnumerable and forgot to change the @inherits TemplatePage statement.

My but.

jzabroski commented 4 years ago

Thanks for the follow up