After upgrading from Visual Studio 2010 to 2012 code started throwing \"ArgumentOutOfRangeException - Index was out of range. Must be non-negative and less than the size of the
After giving this some more investigation, I've come to the conclusion that the problem is the anonymous class I'm returning from the Linq query, I think it isn't allowed anymore to return an anonymous class with only one field in it, I know it isn't needed to wrap the field in an anonymous class but ... as I said this worked before upgrading.
Following example gives me the "ArgumentOutOfRangeException - Index was out of range":
void Main()
{
var iq1 = ActionPlans.Select(ap => ap.ID).ToList();
var iq2 = iq1.Join(ActionPlans.Select(ap => ap.ID),
a => a,
b => b,
(a, b) => new { a });
iq2.Dump();
}
this next example works as expected:
void Main()
{
var iq1 = ActionPlans.Select(ap => ap.ID).ToList();
var iq2 = iq1.Join(ActionPlans.Select(ap => ap.ID),
a => a,
b => b,
(a, b) => a );
iq2.Dump();
}