user2585299
user2585299

Reputation: 883

Linq query output does not match with Sql query output

Repository.Calls
    .Count(call => call.OutcomeActionDate.Value >= fourWeeksStartDate && 
                   call.OutcomeActionDate.Value < threeWeeksStartDate && 
                   call.UserId == user.UserId);

Above query gives me output 1 and the sql query:

select * 
from calls 
where userid = 1006 and
      outcomeactiondate >= '2013-08-19' and
      OutcomeActionDate < '2013-08-26'

gives me the output 15.

The output 15 is correct. I am not sure why is the linq query giving me incorrect value ? All the parameter values used in select query are same as passed in the linq query.

Upvotes: 1

Views: 81

Answers (1)

Sergey Berezovskiy
Sergey Berezovskiy

Reputation: 236188

Try to use Date part of filtered dates:

Calls.Count(call => call.OutcomeActionDate.Value >= fourWeeksStartDate.Date &&
                    call.OutcomeActionDate.Value < threeWeeksStartDate.Date &&
                    call.UserId == user.UserId);

Upvotes: 2

Related Questions