小编Pro*_*nja的帖子

如何在Linq查询中将DateTime转换为String?

我必须以MMM dd,YYYY格式显示日期.

var performancereviews = from pr in db.PerformanceReviews
                                         .Include(a => a.ReviewedByEmployee)
                                 select new PerformanceReviewsDTO
                                 {
                                     ReviewDate=pr.ReviewDate.ToString("MMM dd,yyyy"),
                                     EmployeeName=pr.ReviewedByEmployee.Name,
                                     JobTitle=pr.ReviewedByEmployee.JobTitle,
                                     ReviewerComments=pr.CommentsByReviewer,
                                     EmployeeComments=pr.CommentsByEmployee
                                 };
Run Code Online (Sandbox Code Playgroud)

这是我得到的错误消息

ExceptionMessage:LINQ to Entities无法识别方法'System.String ToString(System.String)'方法,并且此方法无法转换为商店表达式.ExceptionType:System.NotSupportedException

当我申请时ToString,pr.ReviewDate我得到错误.

请指导我正确的解决方案如何实现这一目标.我知道在正常的C#编码中有几个选项可用,但在Linq我们怎么做呢.

c# linq linq-to-entities entity-framework

7
推荐指数
1
解决办法
2万
查看次数

如何在不卸载整个产品的情况下将Visual Studio 2013 Update 5还原到Visual Studio 2013更新4

我必须使用Web Essentials 2013但它不适用于Visual Studio 2013更新5.我必须安装VS 2013更新4才能安装Web Essentials 2013.有没有办法我可以安装VS 2013更新4卸载整个VS 2013更新5以节省时间.

c# ctp4 web-essentials visual-studio-2013

6
推荐指数
1
解决办法
2270
查看次数