I have two datatables with identical schemas, business partners and addresses. I'm trying to combine them in a specific format in order to import into another system.
Basically, I want the output to be as follows:
- Business Partner
- All associated addresses
- Next business partner
- All associated addresses
Here is the latest code I'm trying:
var finalDt = BpDt.Clone();
foreach(DataRow BpRow in BpDt.Rows)
{
finalDt.ImportRow(BpRow);
foreach(DataRow AddressRow in AddressDt.Rows)
{
if(Convert.ToString(BpRow["id"]).Equals(Convert.ToString(BpRow["id"])))
finalDt.ImportRow(AddressRow);
}
}
It seems to get caught in a infinite loop but I don't understand why. Is there a better way to approach this?