2

When tried to condition the where statement to only compare the date part of the datetime field using this code,

var list =  products.Where(x => ((DateTime)x.PurchaseDate).Date >= dt_SelectDate.Value.Date);

I used the (DateTime) conversion because EF don't recognize the .GetValueOrDefault(), and the PurchaseDate field is nullable.

the error I got is

The specified type member 'Date' is not supported in LINQ to Entities. Only initializers, entity members, and entity navigation properties are supported.

abatishchev
  • 98,240
  • 88
  • 296
  • 433
Mustafa Magdy
  • 1,230
  • 5
  • 28
  • 44

1 Answers1

4

I think you need to the the EntityFunctions.TruncateTime method to compare (just) dates.

Here's the MSDN description: http://msdn.microsoft.com/en-us/library/dd395596.aspx

JimMat
  • 308
  • 1
  • 3
  • 7