After having worked in MVC for a few months, I'm back in a previously written WebForms 3.5 application, and I'm trying to fix up what I can with what I've learned.
Part of this is the "strongly-typed model with a partial view" concept which is incredibly awesome. By inheriting my custom "ListTemplate" control, I can then use its GetModel() method to get something resembling this:
<% List<Models.CaseStudy> model = GetModel<Models.CaseStudy>(); %>
I can then run a foreach over model, and all is happy. However, I wanted to do a grouping so I added references to:
<%@ Import Namespace="System.Linq" %>
<%@ Import Namespace="System.Linq.Expressions" %>
Then, with a slightly less-than-ideal syntax, tried this:
<% IEnumerable<IGrouping<string, Models.CaseStudy>> model = GetModel<Models.CaseStudy>().GroupBy(e => e.Client.Name); %>
But no! "Compiler Error Message: CS1525: Invalid expression term '>'" - and it appears to be the lambda at fault. It doesn't work if I put the GroupBy() in the foreach parameters either.
Is there any way to get lambdas working within ASCX files?