c# - Why can't I get LINQ to work in my .cshtml files? -
i'm working in vs 2017, targeting .net framework 4.6.2, , i've been running in few different projects. believe projects created in vs 2012, it's worth.
i'm able use linq extensions , query syntax no problems whatsoever in of .cs files, if try line in .cshtml razor file:
@{ var activecategories = model.categories.where(x => x.articles.count > 0).count(); } <p>active categories: @activecategories</p> i error this:
list<category> not contain definition 'where', , closest extension method accepting first argument of type list<category> not found (are missing using directive or assembly reference?)` i've tried adding using system.linq; top of .cshtml files, shows error can not found.
i've updated web.config under views folder include system.linq, i've checked , project referencing system.core, , i've cleared items in %localappdata%/microsoft/visualstudio/15.0_ba2c3fe6/componentmodelcache.
all philosophy whether or not use linq in views aside, shouldn't happening, right? isn't problem when create new asp.net mvc project, these older projects.
i assuming local environment, other devs don't seem have issue on machines.
why happening, , how can fix it?
Comments
Post a Comment