Linq-to-EF DateTime.ToLocalTime not supported

c#, datetime, linq, linq-to-entities, sql

Solution

Instead of using .ToLocalTime() inside your Linq query, use the opposite conversion outside of the query on the parameters.

var dateUniversal = dateParam.ToUniversalTime();

var query = myTable.Where( t => t.DateTime > dateUniversal );

Problem

`DateTime.ToLocalTime` is not supported in Linq to EF. What's the alternative? I am running out of idea.

Original source

Related problems