Linq to Entity get a Date from DateTime

前端 未结 3 1781
别跟我提以往
别跟我提以往 2021-01-17 17:22

var islemList = (from isl in entities.Islemler where (isl.KayitTarihi.Date >= dbas && isl.KayitTarihi.Value.Date <= dbit) selec

相关标签:
3条回答
  • 2021-01-17 17:58

    The .Date property is not supported in Linq to Entities (though it may be supported in other implementations of Linq).

    I realize that you only want to compare the dates, but there is no real problem with comparing the datetimes if the dbas and dbit values are datetimes with time 00:00:00. You might have to offset the dates or use other inequality checks to get the proper interval but the comparison will work as you intend.

    I would personally go with Jandek's solution.

    0 讨论(0)
  • 2021-01-17 18:09

    Use EntityFunctions.TruncateTime.

    0 讨论(0)
  • 2021-01-17 18:22

    if KayitTarihi is a date column in DB (and dbas and dbit are DateTime), use:

    var islemList = (from isl in entities.Islemler where (isl.KayitTarihi >= dbas && isl.KayitTarihi <= dbit) select isl);
    
    0 讨论(0)
提交回复
热议问题