(from sms in db.sms
where sms.NeedModeration == true && sms.ReplyStatus == "test" && **sms.date.Value == date**
select new
{
SMSID = sms.SmsID,
Body = sms.body,
Date=sms.date,
ReplyStatus = sms.ReplyStatus
}).AsEnumerable().Select(x=>new VMSMS{
SMSID=x.SMSID,
Body=x.Body,
Date= x.Date.Value,
ReplyStatus = x.ReplyStatus
})
给定的代码可以正常工作,但是在哪里我只想匹配 DATETIME 类型的日期部分,例如
sms.date.Value.Date == date.Date
但它不能正常工作它向我显示以下错误
The specified type member 'Date' is not supported in LINQ to Entities. Only initializers, entity members, and entity navigation properties are supported.
那么你能告诉我如何从LINQ 中的 DateTime类型中提取 Date 部分吗?
这是短信 ViewModel 代码....
public class VMSMS
{
public long SMSID { get; set; }
public string SMS { get; set; }
public int? SPOID { get; set; }
public string Body { get; set; }
public string EmployeeName { get; set; }
[IgnoreDataMember]
public DateTime Date { get; set; }
public bool? IsRead { get; set; }
public string DoctorCode { get; set; }
public string ReplyStatus { get; set; }
}