private async static void SearchTextPropertyChanged(BindableObject bindable, object oldvalue, object newvalue) { var vm = (ScanPageViewModel)bindable; if (Settings.Reload) { Debug.WriteLine($"Clearing list"); vm.Suggestions.Clear(); vm.Lookup.Clear(); var contacts = await ServiceProxy.GetAllContacts(); if (contacts == null) { Debug.WriteLine($"Error connecting to D365"); Settings.Reload = false; return; } Debug.WriteLine($"{contacts.Count()} records retrieved from D365"); foreach (var c in contacts) { switch (Settings.SearchAttribute) { case "contactid": if (!vm.Suggestions.Contains($"{c.contactid}")) { vm.Suggestions.Add($"{c.contactid}"); vm.Lookup.TryAdd($"{c.contactid}", $"{c.contactid}"); } break; case "employeeid": if (!vm.Suggestions.Contains($"{c.employeeid}")) { vm.Suggestions.Add($"{c.employeeid}"); vm.Lookup.TryAdd($"{c.employeeid}", $"{c.contactid}"); } break; case "externaluseridentifier": if (!vm.Suggestions.Contains($"{c.externaluseridentifier}")) { vm.Suggestions.Add($"{c.externaluseridentifier}"); vm.Lookup.TryAdd($"{c.externaluseridentifier}", $"{c.contactid}"); } break; case "governmentid": if (!vm.Suggestions.Contains($"{c.governmentid}")) { vm.Suggestions.Add($"{c.governmentid}"); vm.Lookup.TryAdd($"{c.governmentid}", $"{c.contactid}"); } break; case "fullname": if (!vm.Suggestions.Contains($"{c.fullname}")) { var text = (c.parentcustomerid_account != null) ? $"{c.fullname}:{c.parentcustomerid_account.name}" : $"{c.fullname}:"; vm.Suggestions.Add(text); vm.Lookup.TryAdd($"{c.fullname}", $"{c.contactid}"); } break; } } Debug.WriteLine($"{vm.Suggestions.Count()} unique records added to list"); Settings.Reload = false; } }