private async Task ShowExistingWebResources() { if (!this.IsControlsEnabled) { return; } ToggleControls(false, Properties.OutputStrings.LoadingWebResources); string textName = string.Empty; bool? hidden = null; bool? managed = null; int? webResourceType = null; this.Dispatcher.Invoke(() => { this._itemsSource.Clear(); textName = txtBFilter.Text.Trim().ToLower(); if (cmBManaged.SelectedItem is ComboBoxItem comboBoxItemManaged && comboBoxItemManaged.Tag != null && comboBoxItemManaged.Tag is bool boolManaged ) { managed = boolManaged; } if (cmBHidden.SelectedItem is ComboBoxItem comboBoxItemHidden && comboBoxItemHidden.Tag != null && comboBoxItemHidden.Tag is bool boolHidden ) { hidden = boolHidden; } if (cmBType.SelectedItem is WebResource.Schema.OptionSets.webresourcetype webresourcetype) { webResourceType = (int)webresourcetype; } }); IEnumerable <LinkedEntities <WebResource> > list = Enumerable.Empty <LinkedEntities <WebResource> >(); try { var service1 = await GetService1(); var service2 = await GetService2(); if (service1 != null && service2 != null) { var columnSet = new ColumnSet ( WebResource.Schema.Attributes.name , WebResource.Schema.Attributes.displayname , WebResource.Schema.Attributes.webresourcetype , WebResource.Schema.Attributes.ismanaged , WebResource.Schema.Attributes.ishidden ); List <LinkedEntities <WebResource> > temp = new List <LinkedEntities <WebResource> >(); if (service1.ConnectionData.ConnectionId != service2.ConnectionData.ConnectionId) { var repository1 = new WebResourceRepository(service1); var repository2 = new WebResourceRepository(service2); var task1 = repository1.GetListSupportsTextAsync(textName, webResourceType, managed, hidden, columnSet); var task2 = repository2.GetListSupportsTextAsync(textName, webResourceType, managed, hidden, columnSet); var list1 = await task1; var list2 = await task2; foreach (var webresource1 in list1) { var webresource2 = list2.FirstOrDefault(c => string.Equals(c.Name, webresource1.Name, StringComparison.InvariantCultureIgnoreCase)); if (webresource2 == null) { continue; } temp.Add(new LinkedEntities <WebResource>(webresource1, webresource2)); } } else { var repository1 = new WebResourceRepository(service1); var task1 = repository1.GetListSupportsTextAsync(textName, webResourceType, managed, hidden, columnSet); var list1 = await task1; foreach (var webresource1 in list1) { temp.Add(new LinkedEntities <WebResource>(webresource1, null)); } } list = temp; } } catch (Exception ex) { this._iWriteToOutput.WriteErrorToOutput(null, ex); } list = FilterList(list, textName); LoadEntities(list); }