Below runs correctly without error:
IEnumerable<FieldDef> FieldDefQuery =
from fds in FieldDefs
where fds.DispLevel == enumDispLevel.Grid
select fds;
Below runs correctly without error:
IEnumerable<FieldDef> FieldDefQuery =
from fds in FieldDefs
orderby fds.DispOrder ascending
select fds;
Below fails:
IEnumerable<FieldDef> FieldDefQuery =
from fds in FieldDefs
where fds.DispLevel == enumDispLevel.Grid
orderby fds.DispOrder ascending
select fds;
foreach (FieldDef fd in FieldDefQuery)
{
Debug.WriteLine(fd.DispName);
}
With both where and orderby clauses it fails at execution time with the following message:
A first chance exception of type 'System.ArgumentOutOfRangeException' occurred
Parameter name: Parameter index is out of range.
at Gabe2a.GabeLib.FieldDef.get_DispLevel() in
at System.Linq.Enumerable.WhereListIterator`1.MoveNext()
at System.Linq.Buffer`1..ctor(IEnumerable`1 source)
at System.Linq.OrderedEnumerable`1.<GetEnumerator>d__0.MoveNext()
I just cannot figure out how/why where-clause alone is fine and orderby-clause alone is fine but the two clauses together fail
FieldDef DispLevel is just a simply Byte property of FieldDef public byte DispOrder { get { return dispOrder; } set { dispOrder = value; } }
– paparazzo Mar 19 '11 at 13:50