I'm troubleshooting an old application and having a hard time understanding why a variable isn't entering a foreach loop. My problem is that I have very limited experience dealing with Generics/Collections/LINQ. Please excuse me if this is an elementary question.
I have the following variable:
var allegationlist = allegation.Where(x => x.DaType == datype.FirstOrDefault().IntakeServReqTypeKey && x.DaSubType == subtypedetail.FirstOrDefault().ClassKey && x.DaNumber == daNumber);
when I mouse over each element in the where statement, they all have values. Example:
x.DaType == datype.FirstOrDefault().IntakeServReqTypeKey has a value of "Complaint-DSDS"
x.DaSubType == subtypedetail.FirstOrDefault().ClassKey has a value of "IHS"
x.DaNumber == daNumber has a value of "201706218360"
However, if I mouse over allegationlist, the Result View states "Enumeration yielded no results".
When I look into the base, Current is null as is System.Collections.IEnumerator.Current.
When I look into enumerator, Current is null and System.Collections.IEnumerator.Current is
System.Collections.IEnumerator.Current '((System.Linq.Enumerable.WhereListIterator<CaseCompass.Intake.NewIntakeHelper.AllegationHelper>)allegationlist).enumerator.System.Collections.IEnumerator.Current' threw an exception of type 'System.InvalidOperationException' object {System.InvalidOperationException}
If I drill into System.Collections.IEnumerator.Current the base states:
{"Enumeration has either not started or has already finished."} System.SystemException {System.InvalidOperationException}
and the Stack Trace states:
StackTrace " at System.ThrowHelper.ThrowInvalidOperationException(ExceptionResource resource)\r\n at System.Collections.Generic.List`1.Enumerator.System.Collections.IEnumerator.get_Current()" string
There is also a list section with the following information:
[0] {CaseCompass.Intake.NewIntakeHelper.AllegationHelper} CaseCompass.Intake.NewIntakeHelper.AllegationHelper
AllegationId {58323453-1ee3-4cef-ba2a-e1da6fd95c16} System.Guid
AllegationName "Contract" string
DaNumber "201706218360" string
DaSubType "In-Home Services" string
DaType "Complaint-DSDS" string
GridRowIndex 0 int
Indicators Count = 1 System.Collections.Generic.List<string>
ParentGridRowIndex 0 int
SubtypeId "bf713051-359a-4091-9f0f-afa5019304e9" string
Typeid "3cdc658e-947c-497c-8fb1-2bb9dc026baa" string
This same information is also found in the source section
I've Googled the various error messages but I'm not experienced enough to relate what I'm reading with my code.