I work with System.Web.Helpers.WebGrid in an ASP.NET MVC 3 Razor project, and itβs hard for me to understand why the format parameter for WebGridColumn is Func<dynamic, object> .
If I create a column like this ...
grid.Column( format: x => string.Format("{0:d}", x.StartDate) );
... I do not get strong print in the StartDate property. If I try to get around this so ...
grid.Column( format: (MyObjectType x) => string.Format("{0:d}", x.StartDate) );
... I am told at runtime that my lambda cannot be added to Func<dynamic, object> . Is there a way to use a non-dynamic lambda here? Even if it's just <object, object> ?
(I'm in .NET 4.0, and Func<in T, out TResult> should be contravariant on T, but I'm confused about how covariance and contravariance work with dynamic ones.)
source share