.Any() Gives ArgumentOutOfRangeException exception

Posts   
 
    
Posts: 48
Joined: 26-Mar-2007
# Posted on: 22-Jan-2010 14:28:44   

I changed my code from:

                var periodTasks = tasks.Where(t => t.EmployeeFk == employee.Id && t.Start >= extractStart && t.Start < extractEnd);

                if (periodTasks.Count()==0) continue;

to

               var periodTasks = tasks.Where(t => t.EmployeeFk == employee.Id && t.Start >= extractStart && t.Start < extractEnd);

                if (!periodTasks.Any()) continue;

and now I get:

System.ArgumentOutOfRangeException occurred Message="Index was out of range. Must be non-negative and less than the size of the collection.\r\nParameter name: index" Source="mscorlib" ParamName="index" StackTrace: at System.ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument argument, ExceptionResource resource) InnerException:

Not sure if this is just me using LinQ incorrectly or an LLBLGenPro issue

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39865
Joined: 17-Aug-2003
# Posted on: 22-Jan-2010 18:37:48   
Frans Bouma | Lead developer LLBLGen Pro