コード例 #1
0
        // Find the specified entitySetName in the list or add it if it's not there
        private EntityDataSourceEntitySetNameItem FindEntitySetName(string entitySetName)
        {
            if (!String.IsNullOrEmpty(entitySetName))
            {
                EntityDataSourceEntitySetNameItem entitySetToSelect = null;
                foreach (EntityDataSourceEntitySetNameItem entitySetNameItem in _entitySetNames)
                {
                    // 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(entitySetNameItem.EntitySetName, entitySetName, StringComparison.OrdinalIgnoreCase))
                    {
                        entitySetToSelect = entitySetNameItem;
                    }
                }

                // didn't find a matching entityset, so just create a placeholder for one using the specified name and add it to the list
                if (entitySetToSelect == null)
                {
                    entitySetToSelect = new EntityDataSourceEntitySetNameItem(entitySetName);
                    _entitySetNames.Add(entitySetToSelect);
                }

                Debug.Assert(entitySetToSelect != null, "expected a non-null EntityDataSourceEntitySetNameItem");
                return(entitySetToSelect);
            }

            return(null);
        }
コード例 #2
0
        // Populates the EntitySetName combobox with all of the discoverable EntitySets for the specified container.
        // If the specified entitySetName is not empty, it is added to the list and selected as the initial value
        // containerNameItem may not be backed by a real EntityContainer, in which case there is no way to look up the EntitySet in metadata
        // devnote: This method should not automatically reset EntityTypeFilter and 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 LoadEntitySetNames(EntityDataSourceContainerNameItem containerNameItem, string entitySetName)
        {
            // If this is a container that we found in the project's metadata, get a list of EntitySets for that container
            if (containerNameItem != null && containerNameItem.EntityContainer != null)
            {
                _entitySetNames = _helper.GetEntitySets(containerNameItem.EntityContainer, false /*sortResults*/);

                // Try to find the specified entityset in list and add it if it isn't there
                _selectedEntitySetName = FindEntitySetName(entitySetName);
            }
            else
            {
                // if this is an unknown container, there is no way to find a list of entitysets from metadata
                // so just create a new list and placeholder for the specified entityset
                _entitySetNames = new List <EntityDataSourceEntitySetNameItem>();
                if (!String.IsNullOrEmpty(entitySetName))
                {
                    _selectedEntitySetName = new EntityDataSourceEntitySetNameItem(entitySetName);
                    _entitySetNames.Add(_selectedEntitySetName);
                }
                else
                {
                    _selectedEntitySetName = null;
                }
            }

            // Sort the list now, after we may have added one above
            _entitySetNames.Sort();

            // Update the controls
            _panel.SetEntitySetNames(_entitySetNames);
            _panel.SetSelectedEntitySetName(_selectedEntitySetName);
        }
コード例 #3
0
 // Set EntitySetName in temporary storage
 internal void SelectEntitySetName(EntityDataSourceEntitySetNameItem selectedEntitySet)
 {
     _selectedEntitySetName = selectedEntitySet;
     // Load the types for the selected EntitySet, don't select one initially
     LoadEntityTypeFilters(selectedEntitySet, null);
     // Reinitialize the Select control with a list of properties, don't preserve any existing Select value
     LoadSelect(String.Empty);
 }
コード例 #4
0
 public void SetSelectedEntitySetName(EntityDataSourceEntitySetNameItem selectedEntitySet)
 {
     _ignoreEvents = true;
     if (selectedEntitySet == null)
     {
         _entitySetComboBox.SelectedIndex = -1;
     }
     else
     {
         _entitySetComboBox.SelectedItem = selectedEntitySet;
     }
     _ignoreEvents = false;
 }
コード例 #5
0
        // 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);
        }