0

Why this code throws a System.NotSupportedException telling that The specified method 'int? DateDiff(string, DateTime?, DateTime?)' on the type 'System.Data.Objects.SqlClient.SqlFunctions' cannot be translated into a LINQ to Entities store expression, though DateDiff has EdmFunction attribute?

context.Users.Where(f => System.Data.Objects.SqlClient.SqlFunctions.DateDiff("second", f.LastLogOn, somedatetime) < 0)

1 Answer 1

2

Here is a complete enumeration of canonical Date and Time functions supported by Entity SQL query provider link.

Try something like this

context.Users.Where(f=>EntityFunctions.DiffSeconds(f.LastLogOn, somedatetime)<0);
Sign up to request clarification or add additional context in comments.

3 Comments

Thanks for answer, but this is SqlCe not Sql Server, it does not support any compare functions other than DateDiff.
As far as I understand this function will be translated into DateDiff. Give it a try :)
For the Entity Framework version 6, consider to use DbFunctions.DiffSeconds

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.