I have a sql-server-ce 4 database having a table with a DateTime?
column named EndDate. When I delete a record I set this enddate and when I want to retrieve a list of records, I want to filter all the deleted records by applying a filter on the enddate.
I apply this filter via linq using entity framework.
My linq query looks like this:
protected IDbSet<TEntity> Entities;
...
Entities.AsNoTracking().AsQueryable()
.Where(entity => !entity.EndDate.HasValue || entity.EndDate.Value > DateTime.UtcNow);
When I execute this linq query I get the following error:
The function 'CurrentUtcDateTime' is not supported by SQL Server Compact.
Searching on this error tells me that (if I have understood it correctly) I cannot use DateTime.UtcNow.
My question is: What is the alternative way to reach the goal I try to reach?
Is there a different function I can use via linq? Or should I use a more primitive solution where I also convert the datetime to an Epoch and compare those?