Thursday, November 6, 2014

DbArithmeticExpression arguments must have a numeric common type


DbArithmeticExpression arguments must have a numeric common type Solution: we can't put datediff directly in linq / lambda.. instead of that we should use like : EntityFunctions.DiffMinutes Eg:
              dgvProfiles.DataSource = (from profile in dbModel.ProfileMasters
                                         select new
                                         {
                                             ProfileID = profile.ProfileId,
                                             Profile = profile.ClientName,
                                             Tasks= profile.TaskMasters.Count(),
                                             AverageTime = profile.TaskMasters.Select(x => EntityFunctions.DiffMinutes(x.StartTime, x.EndTime)).Average(y => (decimal?)y.Value),
                                             LastTime = profile.TaskMasters.Max(x=>x.StartTime)
                                         }).ToList();

Share This!


No comments:

Powered By Blogger · Designed By Seo Blogger Templates