0

Im setting value in a variable like this:

var billing = context.Payload.QuestionGroupList.Where(x => x.GroupCode.ToLower().Equals("yourinfo"));

But problem is, I get null exception when I query it. Although I have kept a null check but it passes this check and when I expand the resultview I see 'enumeration yielded no result'

I get NULL reference exception since billing is empty on the following line. So my question is what further check I can apply to avoid it?

if (billing != null)
{
   billingAddress = billing.FirstOrDefault().QuestionList.Where(x => x.Code.ToLower().Equals("billingaddressques")).Select(x => new Question { QuestionAnswer = x.QuestionAnswer, Code = x.Code }).ToList();
}
Huma Ali
  • 1,759
  • 7
  • 40
  • 66

0 Answers0