I am trying to convert a datetime field to a string. The error message I got is found below. Have you seen this before? I am not getting a solution. How can I resolve this please?
public IEnumerable<SelectListItem> GetStatusDate(string strprojectId)
{
var queryResult = (from dt in _objContext.tbl_Project_Status_MSTR
where dt.ProjectID.Equals(strprojectId)
orderby dt.ProjectID
select new SelectListItem {Text = Convert.ToString(dt.StatusDate),Value = Convert.ToString(dt.StatusDate)});
List<SelectListItem> objStatDate = queryResult.ToList();
return objStatDate;
}
LINQ to Entities does not recognize the method 'System.String ToString(System.DateTime)' method, and this method cannot be translated into a store expression.
dt.StatusDate.ToString()which will be converted to expression.