This code throws an error:
void GetLog()
{
List<CAR_STATUS_LOGS> logs = null;
using (TESTEntities ctx = new TESTEntities())
{
logs =
ctx.CAR_STATUS_LOGS
.Where(a => SqlFunctions.DatePart("DAY", a.TIMEMARK) == 1)
.ToList();
}
}
Error:
LINQ to Entities does not recognize the method 'System.Nullable`1 [System.Int32] DatePart (System.String, System.Nullable`1 [System.DateTime])', and this method cannot be translated into a stored expression.
I do not see what I am doing wrong with SqlFunctions.DatePart. The TIMEMARK column is a type of Sqlserver DateTime.
Any ideas?
source
share