I need to patch new items to dbo.ChecklistItems (a SQL table) from template (colTemplate). I create a ForAll loop to copy the data from template to a temporary collection "colPatch". Then patch my SQL table at once. Here is my code:
ForAll(colTemplate,
If(IsBlank(LookUp('dbo.ChecklistItems',colTemplate[@ID]='dbo.ChecklistItems'[@TemplateID] && CertID=varCurrentTest.ID)),
Collect(colPatch,
{
Title:DataCardValue2.Text,
TemplateID:ThisRecord.ID,
TestType:varTestID,
CertID:varCurrentTest.ID
});
));
Patch(
'dbo.ChecklistItems',
ForAll(
Sequence(CountRows(colPatch)),
Defaults('dbo.ChecklistItems')
),
colPatch
);
Clear(colPatch);
It takes about 13second to patch 150 items. Is there any way to improve the performance?


Report
All responses (
Answers (