How can I convert DateTime to String in Linq Query?

前端 未结 2 786
自闭症患者
自闭症患者 2020-12-18 00:07

I have to display date in MMM dd,YYYY format.

var performancereviews = from pr in db.PerformanceReviews
                                               


        
2条回答
  •  隐瞒了意图╮
    2020-12-18 00:18

    The way I generally solve this problem is by first just getting the data and then selecting it in memory'.

    var performancereviews = from pr in db.PerformanceReviews
                                          .Include(a => a.ReviewedByEmployee)
                                          .ToArray()
                                          .Select( ....);
    

    By putting ToArray (or to List or whatever) it'll finish the sql query part and then do the rest from the collection in memory - which should be fine.

提交回复
热议问题