使用以下代码时:
var _contacts = from cf in context.ContactFields
join c in context.Contacts
on cf.ContactId equals c.Id into contacts
from c in contacts.AsEnumerable()
where c.ClientId == clientId
&& cf.ClientDefinedFieldId == clientDefinedFieldId
&& (((cf.FieldValue != null && Date != null) ? (Convert.ToDateTime(cf.FieldValue).Day == Date.Day && Convert.ToDateTime(cf.FieldValue).Month == Date.Month) : false))
select c;
和实体是
public class ContactField : IEntity
{
public int Id { get; set; }
public string FieldValue { get; set; }
public int ClientDefinedFieldId { get; set; }
}
然后它在运行时给出错误:
LINQ to Entities无法识别方法' System.DateTime(System.String)'方法,并且此方法无法转换为商店表达式。
有没有办法将字符串值转换为datetime并比较......?