I run into trouble when learning more about the Entity Framework and LINQ.
I am trying to find values from a database that match a specific date.
I have 1.250.000 entries and 36300 of them are from a specific date.
I am using plain old SQL until now and want to practice LINQ to refactor my application to work with the EF.
Can you tell where my mistake is?
The second way works but takes a lot of time ~15 sec
Where(Function(d) d.ExportedDate.HasValue AndAlso d.ExportedDate.Value = exportDate)
On this way you select only rows where the nullable column
ExportedDate is not null and where it equals the given date.
Date as opposed to
d.ExportedDate which is a
Date?. If you compare a
Date? with a
Date you get a
Boolean? as result(not a
Nothing means undefined.
This is an interesting difference to C#, related: Why is there a difference in checking null against a value in VB.NET and C#?
To fix the next error: append
ToList to create a list.