I am confused to understand the difference between Linq's Count() for IQueryable and Linq's Count() for IEnumerable.
I have the following method which has to return the same result of the counts, but enumerableCount equals 2 while queryableCount is 0:
public List<int> GetMembersCount()
{
var queryableQuery = MemberRepository.GetAll().Include(p => p.Message);
var enumerableQuery = MemberRepository.GetAll().Include(p => p.Message).ToList();
var queryableCount = queryableQuery.Count(m => m.Message.Deadline.Date == DateTime.Today);
var enumerableCount = enumerableQuery.Count(m => m.Message.Deadline.Date == DateTime.Today);
return new List<int>
{
enumerableCount,
queryableCount
};
}
Can anybody explain what is going on? I am using PostgreSQL and Entity Framework