// Set EntityTypeFilter in temporary storage and load the Select property internal void SelectEntityTypeFilter(EntityDataSourceEntityTypeFilterItem selectedEntityTypeFilter) { _selectedEntityTypeFilter = selectedEntityTypeFilter; // Reinitialize the Select control with a list of properties, don't preserve any existing Select value LoadSelect(String.Empty); }
// Populate a list with the base type for the EntitySet plus all derived types, and a special entry to indicate no filter // devnote: This method should not automatically reset Select because it can be used to load the initial state // for the form, in which case we need to preserve any values that are already set on the data source control. private void LoadEntityTypeFilters(EntityDataSourceEntitySetNameItem entitySetItem, string entityTypeFilter) { // If this is an EntitySet that we found in the project's metadata, get the type information if (entitySetItem != null && entitySetItem.EntitySet != null) { _entityTypeFilters = _helper.GetEntityTypeFilters(entitySetItem.EntitySet.ElementType, false /*sortResults*/); // add (None) to the beginning of the list _entityTypeFilters.Insert(0, s_entityTypeFilterNoneItem); // Try to find the specified type in list and add it if it isn't there _selectedEntityTypeFilter = FindEntityTypeFilter(entityTypeFilter); } else { // if this is an unknown EntitySet, there is no way to find a list of types from metadata // so just create a new list and placeholder for the specified type _entityTypeFilters = new List<EntityDataSourceEntityTypeFilterItem>(); _entityTypeFilters.Add(s_entityTypeFilterNoneItem); if (!String.IsNullOrEmpty(entityTypeFilter)) { _selectedEntityTypeFilter = new EntityDataSourceEntityTypeFilterItem(entityTypeFilter); _entityTypeFilters.Add(_selectedEntityTypeFilter); } else { _selectedEntityTypeFilter = s_entityTypeFilterNoneItem; } } // Sort now after we might have added items above _entityTypeFilters.Sort(); // Update the controls _panel.SetEntityTypeFilters(_entityTypeFilters); _panel.SetSelectedEntityTypeFilter(_selectedEntityTypeFilter); }
// Find the specified entityTypeFilter in the list and add it if it's not there private EntityDataSourceEntityTypeFilterItem FindEntityTypeFilter(string entityTypeFilter) { if (!String.IsNullOrEmpty(entityTypeFilter)) { EntityDataSourceEntityTypeFilterItem typeToSelect = null; foreach (EntityDataSourceEntityTypeFilterItem entityTypeFilterItem in _entityTypeFilters) { // Ignore case here when searching the list for a matching item, but set the temporary state property to the // correctly-cased version from metadata so that if the user clicks Finish, the correct one will be saved. This // allows some flexibility the designer without preserving an incorrectly-cased value that could cause errors at runtime. if (String.Equals(entityTypeFilterItem.EntityTypeName, entityTypeFilter, StringComparison.OrdinalIgnoreCase)) { typeToSelect = entityTypeFilterItem; } } // didn't find a matching type, so just create a placeholder item and add it to the list if (typeToSelect == null) { typeToSelect = new EntityDataSourceEntityTypeFilterItem(entityTypeFilter); _entityTypeFilters.Add(typeToSelect); } Debug.Assert(typeToSelect != null, "expected a non-null string for EntityTypeFilter"); return typeToSelect; } return s_entityTypeFilterNoneItem; }
public void SetSelectedEntityTypeFilter(EntityDataSourceEntityTypeFilterItem selectedEntityTypeFilter) { Debug.Assert(selectedEntityTypeFilter != null, "cannot select null from EntityTypeFilter combobox"); _ignoreEvents = true; _entityTypeFilterComboBox.SelectedItem = selectedEntityTypeFilter; _ignoreEvents = false; }