Hey everyoneI have this aggerate, let call it GetAByIdGetAById = 1 return 4 record with attribute BId = 1,2,3,4I have a structure with about 20 attribute, how do i append those BId to the attribute in the structure?Examplestructure.attribute1 = 1structure.attribute2 = 2structure.attribute3 = 3structure.attribute4 = 4structure.attribute5 = null...structure.attribute20 = nullI try to use some assign like thisstructure.attribute1 = GetAById.List[0].Entity.Bidstructure.attribute2 = GetAById.List[1].Entity.Bid ...structure.attribute20 = GetAById.List[19].Entity.BidThe first 4 one work normal since they have data inside the DB, but to the fifth one it return an error "Index 4 is out of range"I try to loop the aggerate but seem like there's no way to increase the structure number(Attribute 1->attribute2)Thank you!
I think you may need to do a if/else check on GetAById.List.Length before trying to execute GetAById.List[X]. if X is < Length, proceed to assign, else don't try to assign.
@john cop
Aggreged with Stephen. I don't see any other option rather than adding explicit checking before assigning. Doing index operation is risky.
Assign only when
GetAById .Length > x for structure.attribute1 = GetAById.List[x].Entity.Bid