Q:

Entity Framework returns 0 results in spite of the data in the tables when `DbFunctions.DiffDays(DateTime.Now, c.ModifiedDate)` is used in the query

The below code should return the result from the table which has status = 1 and the data is older than 90 days. In the table there are a lot of data which has modified date more than90 days.
But this code is returning 0 results.
The datetime difference throws error so used DbFunctions instead since EF I am using is EF6.
IEnumerable<IncentiveClaim> claims = repository.Table
                      .Where(c => c.Status == 1 
                        && DbFunctions.DiffDays(DateTime.Now, c.ModifiedDate) >= 90)
                      .AsEnumerable();

A:

The method has parameter as DbFunctions.DiffDays(smallestDateTime, LargestDateTime). So, the ModifiedDate should be first parameter and DateTime.Now should be second parameter. Then, you have to call .Value on the method to get the no. of days.
Modify the code as below:
IEnumerable<IncentiveClaim> claims = repository.Table
           .Where(c => c.Status == 1 
            && DbFunctions.DiffDays(c.ModifiedDate, DateTime.Now).Value >= 
            90)
            .ToList();

