Note that there are some explanatory texts on larger screens.

plurals
  1. PONested foreach loop slow
    primarykey
    data
    text
    <p>The following piece of code achives the desired results, but performance is extremely slow: </p> <pre><code>SearchResultCollection absaUsers = ABSAds.FindAll(); SearchResultCollection srcUsers = ds.FindAll(); foreach (SearchResult users in srcUsers) { string cn = users.Properties["cn"][0].ToString(); string sn = users.Properties["sn"][0].ToString(); string userID = users.Properties["uid"][0].ToString(); string description = users.Properties["PersonnelAreaDesc"][0].ToString(); string jobCodeID = users.Properties["JobcodeID"][0].ToString(); string CostCentreID = users.Properties["costCentreID"][0].ToString(); string CostCentreDescription = users.Properties["CostCentreDescription"][0].ToString(); string givenName = users.Properties["givenName"][0].ToString(); string employmentStatus = users.Properties["EmploymentStatus"][0].ToString(); string EmploymentStatusDescription = users.Properties["EmploymentStatusDescription"][0].ToString(); foreach (SearchResult absaUser in absaUsers) { string absaUID = absaUser.Properties["uid"][0].ToString(); string absaEmploymentStatus = absaUser.Properties["EmploymentStatus"][0].ToString(); string absaEmploymentStatusDescription = absaUser.Properties["EmploymentStatusDescription"][0].ToString(); string absaEmployeeNumber = absaUser.Properties["employeeNumber"][0].ToString(); if (absaUID == cn &amp;&amp; absaEmployeeNumber==userID) { Console.WriteLine("User Record Found:" + cn); sw.WriteLine("Modify" + "," + cn + "," + description + "," + userID + "," + givenName + "," + sn + "," + jobCodeID + "," + CostCentreID + "," + CostCentreDescription + "," + sn + "," + cn + "," + employmentStatus + "," + EmploymentStatusDescription); sw.Flush(); break; } } } </code></pre> <p>It loops through 2 collections and mtaches the outer loops attributes with the inner's. Any suggestions on how I can optimise the performance? </p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload