Let's say we have an ASP.NET MVC View like this:
<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<dynamic>" %>
<%: Html.EditorFor(model => model.ServiceDate) %>
<%: Html.ValidationMessageFor(model => model.ServiceDate, "*")%>
and we have Model classes that are similar but not exactly the same, for instance Invoice and Quote, which both contain the ServiceDate property. Those two classes do not inherit from the same base class, actually they have no base class currently.
How can I get them to inherit from the same base class when those two are generated by EF? If I would be able to do that, I could replace the
dynamicand specify the base class as the View's strong type.I was under impression that this was the case that
dynamicwas built for. But obviously it does not work because there's an exception that's apparently coming from LINQ to EF:CS1963: An expression tree may not contain a dynamic operation
Although it does say in the VS 2010 editor that expression will be resolved at runtime, it is not, but fails in error.