Forum Discussion
Zahar_Chernov
9 years agoCreator II
As I'm not sure if all 30K rows are from the same "source_id" I'll assume they are and I'll assume that you know the ID of the source_id
You don't need to send relationship one-by-one, you can write something like this:
string AML = "" +
"<Item type='MasterList' action='merge' id='{SOURCE_ID}'>" +
" <Relationships>";
for (I=0; I<SQLResult.getItemCount(); I++) {
AML += " <Item type='MasterList_Part' action='add'><related_id>";
//If you know the ID of the "related_id" (child) item use following row:
AML += "{ID or the child item}";
// - OR -
//If you know the KEYED_NAME of the "related_id" (child) item use following row:
AML += "<Item action='get'><keyed_name>{KEYED_NAME OF THE CHILD ITEM}</keyed_name></Item>";
AML += "</related_id></Item>";
}
if (!string.IsNullOrEmpty(AML))
Item qryResult = this.getInnovator().applyAML("<AML>" + AML + "</AML>");
To optimize even more:
- If your rows "source_id" is different you can select all source_id (distinct) from your SQLResult (LINQ can be good idea) and update my example code so it will run based on source_id.
- You can use .NET async to split data loading to couple threads to speed up your code.