I'm somewhat new to Entity Framework (4). I've been tracking down a bug in our software, and I've nailed it down the follow quirk. I'm curious if anyone can help me explain why these two Counts (dataCount and data2Count) would be different depending on the way I've invoked them. data2Count is correct and actually matches up with what I have in SQL.
using (var context = new Entities(ConnectionString))
{
var startDateTime = DateTime.Parse("10/1/2011");
var endDateTime = DateTime.Parse("12/31/2011 23:59");
var query = from data in context.vDATA
where data.ParentId == parentId &&
data.TimeStamp >= startDateTime &&
data.TimeStamp <= endDateTime
select data;
var data = query.ToList();
var dataCount = data.Where(x => x.TestType == 20).Count();
//dataCount is 162
var data2 = query.Where(x => x.TestType == 20);
var data2Count = data2.Count();
//data2Count is 198
}
Thanks.