用linq查找某一天的数据?
db.mytable.Where(t => t.uid == uid && System.Data.Linq.SqlClient.SqlMethods.DateDiffDay(t.dateadd, dateadd) == 0).FirstOrDefault();
报错:LINQ to Entities 不识别方法“System.Nullable`1[System.Int32]
我不知这样写对不对,还是有其它方法?
------解决方案--------------------LINQ to Entities 可以使用SqlFunctions.DateDiff
db.mytable.FirstOrDefault(t => t.uid == uid &&
System.Data.Objects.SqlClient.SqlFunctions.DateDiff("day", t.dateadd,dateadd)==0;