有人指出这个问题吗? 继续获取“LINQ to Entities不支持指定的类型成员'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.Date) == reminderDate.Date
&& reminderDate.Date > EntityFunctions.TruncateTime(c.StartTime.Date));
return apps;
}
答案 0 :(得分:2)
从您的方法中移除所有.Date
但是:
DateTime reminderDate = DateTime.Today.Date;
EntityFramework不支持.Date
的{{1}}属性。出于这个原因,存在伪函数Datetime
,而对于EntityFunctions.TruncateTime
,您已经删除了reminderDate
中的时间。
DateTime reminderDate = DateTime.Today.Date
答案 1 :(得分:0)
试试这个
public IEnumerable<Appointment> FindAllAppointmentsWithReminders()
{
DateTime reminderDate = DateTime.Today.Date;
**DateTime NewDate =reminderDate.Date;**
IEnumerable<Appointment> apps = RepositorySet
.OfType<Appointment>()
.Include("Client")
.Where(c => EntityFunctions.TruncateTime(c.Client.Reminder.Date) == **NewDate**
&& reminderDate.Date > EntityFunctions.TruncateTime(c.StartTime.Date));
return apps;
}