I am using EntityFramework 4, LINQ and C #.
I need display data in a GridView from a query expression using Linq; I need a project as an anonymous type value, calculated on the fly DateTime.UtcNow - cl.DateLocked Note: cl.DateLocked is of type DateTime , and I need to know how many days the difference between the two dates.
With this request, I get an error:
DbArithmeticExpression arguments must have a numeric common type.
Any idea how to do this in Linq? If Linq doesn't let him do it differently?
thank you for your time
var queryContentsLocked = from cl in context.CmsContentsLockedBies join cnt in context.CmsContents on cl.ContentId equals cnt.ContentId join u in context.aspnet_Users on cl.UserId equals u.UserId select new { cl.DateLocked, cnt.ContentId, cnt.Title, u.UserName, u.UserId, TimePan = DateTime.UtcNow - cl.DateLocked
source share