I need to translate a field from UTC to local time in a LINQ to Entities query. But it does not recognize the method \'System.DateTime ToLocalTime\' that I was intended to use.
To be able to use functions that don't translate to SQL, you need to materialize the table.
var materializedRequests = Requests.Where(x => !x.Resolved).ToList(); //Materialize list with a ToList call
materializedRequests
.Where(x =>
!materializedRequests.Any(y =>
y.IncommingDateTime.ToLocalTime().Day == x.IncommingDateTime.ToLocalTime().Day
)
)
Then you can use pretty much any functions you want. However, materializing the list is a VERY expensive call. Try to filter the list as much as you can before you materialize it.