score:2

Accepted answer

You can use LINQ to join both data lists. More about it here.

class Plan {
  public int PlanCode { get; set; }
  public string PlanShortName { get; set; }
}

class Division {
  public int DivisionCode { get; set; }
  public string DivisionName { get; set; }
}

class DivisionAssignment {
  public int PlanCode { get; set; }
  public List<Division> Divisions { get; set; }
}

public static void JoinExample() {
  // do your deserialization stuff here
  List<Plan> plans = ...;
  List<DivisionAssignment> assignments = ...;

  // join the data
  var query = from plan in plans
              join assignment in assignments on plan.PlanCode equals assignment.PlanCode
              select new { PlanCode = plan.PlanCode, Divisions = assignment.Divisions };

  // reach the joined data
  foreach (var planDivision in query) {
    ... = planDivision.PlanCode;
    ... = planDivision.Divisions;
    ...
  }
}

Related Articles