LINQ to Entities 不识别方法“System.String ToString(System.String)”,因此该方法无法转换为存储表达式。
public ActionResult GetNewsList()
{
var newsList = _newsRepository.GetNewsList();
var newsViewList = newsList.Select(news => new NewsViewModel()
{
Id = news.Id,
Title = news.Title,
Content = news.Content,
CategoryName = news.Category.Name,
PublishDate = news.PublishDate.ToString("yyyy-MM-DD HH:mm:ss"),
UpdateDate = news.UpdateDate.ToString("yyyy-MM-DD HH:mm:ss"),
IsActived = news.IsActived ? "是" : "否"
});
return Json(newsViewList, JsonRequestBehavior.AllowGet);
}