score:2

Accepted answer

In your first method, the return type of the Expression is a nullable TResult so all you need to do is return that. This can be done with a cast:

_dbContext.Items
    .Where(i => i.Id == '...')
    .FirstOrDefault(i => (DateTime?)i.Modified, DateTime.Now);

Related Query