views:

78

answers:

3

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

It gives error: date is not supported in LINQ to Entities... How can i get date in linq.

+1  A: 

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);
Jaroslav Jandek
KayitTarihi is DateTime but i need just Date
serkan
Jaroslav Jandek
A: 

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.

Streamcap
+1  A: 

Use EntityFunctions.TruncateTime.

Stephen Cleary