In LINQ Query convert the string to datetime and check with today's date

后端 未结 6 1441
情歌与酒
情歌与酒 2021-01-24 17:24

In Table, DueDate data type is varchar. Now I want to check the due date with today\'s date

 var query = (from o in db.Order_Reports
              where Convert.         


        
6条回答
  •  别那么骄傲
    2021-01-24 17:57

    yes this a problem in Linq-to-Entities this case happend when regular DateTime except that it is nullable

    Linq can understand Convert.ToDateTime or GetValueOrDefault()

    But Entitie Not sported that

    you cane use Date.Value
    this Code :

    var x = myContext.MyTable.Where(tbl => tbl .MyDateColumn.Value == DateTime.Now)
    

提交回复
热议问题