In the LINQ instruction below, I want to select people with an exam date in 2010. The exam date is stored as a date-time, since the actual date and time are used in other applications. What is the most elegant, easiest and best way to compare exzam date only with "2010". Or, if I just compare, using> =, the exam date is before 1/1/2010?
var active = dc.People.Where(x => x.exam >= 2010) .Select(x => new {x.ContactID, x.FirstName, x.LastName}) ); x.MostRecent == DateTime.Parse("1/1/2010").Year
CHANGE NO. 1
I thought I should see a year on the exam, but I did not. After seeing a couple of posts here, I came back and found that this works ...
.Where(x => x.exam.Value.Year == 2010)
Why do I need access. An exam is a date and time with a value of zero.
linq entity-framework entity-framework-4
Denali hardtail
source share