Skip to content


Subversion checkout URL

You can clone with
Download ZIP


ArgumentOutOfRange exception when using Count() and ElementAt(), First() #190

nikoladj13 opened this Issue · 1 comment

2 participants


Hi all,

I am new to Massive. Tried to implement it and in general it works fine. However, occasionally i face a strange problem with ElementAt and First methods. Here is the code sample:

var calcualtionRows = tableCalculation.All();                 
if (calcualtionRows.Count() == 0)
var calculationId = calcualtionRows.ElementAt(0).id; //here it crash with the following exception:

Source: System.Core;
Target site: TSource ElementAt[TSource (System.Collections.Generic.IEnumerable1[TSource], Int32);
Message: Specified argument was out of the range of valid values.
Parameter name: index;
StackTrace: at System.Linq.Enumerable.ElementAt[TSource](IEnumerable
1 source, Int32 index)

Very similar message i get with First method instead of ElementAt.

Basically, i face this problem once per 10-20 runs. Any idea would be appreciated.



Best to ask this on StackOverflow - this isn't an issue with Massive. But, to answer your question this is because you're asking for an element at position 0 and there isn't one. What you want to use is FirstOrDefault().

@robconery robconery closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.