When I do the following :
[EdmFunction(\"Edm\", \"TruncateTime\")]
public static DateTime? TruncateDateTime(DateTime? inputDate)
{
return inputDate.HasV
Try using SqlFunctions.DatePart.
e.g. instead of
var employeeSelection = (from c in MyContext.Employees
.Where(c => c.From.HasValue && GetTotalSeconds(c.To) != 0)
try something like
var employeeSelection = (from c in MyContext.Employees
.Where(c => c.From.HasValue && SqlFunctions.DatePart("second", c.To) != 0)
For NetMage
var employeeSelection = (from c in MyContext.Employees
.Where(c => c.From.HasValue && (SqlFunctions.DatePart("second", c.To) + (60 * SqlFunctions.DatePart("minute", c.To)) + (3600 * SqlFunctions.DatePart("hour", c.To))) != 0)
Where
TotalSeconds = (SqlFunctions.DatePart("second", c.To) + (60 * SqlFunctions.DatePart("minute", c.To)) + (3600 * SqlFunctions.DatePart("hour", c.To)))
If you have a Linq-To-Entities Query you can only perform operations which can be executed by your used database management system.
You will need to get your desired information from your DB and create a list from that query, than that will be called Linq-To-Objects and you will be able to perform you desired operation.
Have a look at Date and Time Canonical Functions for LINQ-to-Entities and if you are unsure on how to call them, have a look at How to: Call Canonical Functions
The methods that are available should be able to solve the problem your currently having where the operations your currently using are not supported by the database.