Anyone point out the issue? Keep getting "The specified type member 'Date' is not supported in LINQ to Entities. Only initializers, entity members, and entity navigation properties are supported."
public IEnumerable<Appointment> FindAllAppointmentsWithReminders()
{
DateTime reminderDate = DateTime.Today.Date;
IEnumerable<Appointment> apps = RepositorySet
.OfType<Appointment>()
.Include("Client")
.Where(c => EntityFunctions.TruncateTime(c.Client.Reminder.Date) == reminderDate.Date
&& reminderDate.Date > EntityFunctions.TruncateTime(c.StartTime.Date));
return apps;
}
Remove all the .Date from your method but this:
DateTime reminderDate = DateTime.Today.Date;
EntityFramework doesn't support the .Date property of Datetime. For this reason there is the pseudo-function EntityFunctions.TruncateTime, and for the reminderDate you already remove the time in the DateTime reminderDate = DateTime.Today.Date.
public IEnumerable<Appointment> FindAllAppointmentsWithReminders()
{
DateTime reminderDate = DateTime.Today.Date;
IEnumerable<Appointment> apps = RepositorySet
.OfType<Appointment>()
.Include("Client")
.Where(c => EntityFunctions.TruncateTime(c.Client.Reminder) == reminderDate
&& reminderDate > EntityFunctions.TruncateTime(c.StartTime));
return apps;
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With