src/Misc/EFTools/EntityDesignModel/Commands/DeleteUnmappedStorageEntitySetsCommand.cs
/// <summary>
///     constructs the list of StorageEntitySet objects that will be unmapped if the
///     conceptual EntityTypes are deleted (including all StorageEntitySet objects
///     which were already unmapped)
/// </summary>
/// <param name="elementsToBeDeleted">collection of conceptual EFElements being considered for deletion</param>
/// <returns>
///     the list of StorageEntitySet objects that will be unmapped if the
///     conceptual EntityType is deleted
/// </returns>
constructs the list of StorageEntitySet objects that will be unmapped if the
conceptual EntityTypes are deleted (including all StorageEntitySet objects
which were already unmapped)
constructs the list of StorageEntitySet objects that will be unmapped if the conceptual EntityTypes are deleted ( including all StorageEntitySet objects which were already unmapped )
internal static ICollection<StorageEntitySet> UnmappedStorageEntitySetsIfDelete(ICollection<EFElement> elementsToBeDeleted)
        {
            var unmappedStorageEntitySets = new HashSet<StorageEntitySet>();
            if (null == elementsToBeDeleted)
            {
                Debug.Fail("elementsToBeDeleted should not be null");
                return unmappedStorageEntitySets;
            }
            var allCSideObjectsThatWouldBeDeleted = new HashSet<EFObject>();
            var storageEntitySetsAtRiskOfDeletion = new HashSet<StorageEntitySet>();
            foreach (var elementToBeDeleted in elementsToBeDeleted)
            {
                var cSideObjectsThatWouldBeDeleted = ConceptualObjectsToBeDeleted(elementToBeDeleted);
                allCSideObjectsThatWouldBeDeleted.UnionWith(cSideObjectsThatWouldBeDeleted);
                storageEntitySetsAtRiskOfDeletion.UnionWith(
                    FindMappedStorageEntitySets(cSideObjectsThatWouldBeDeleted));
            }
            foreach (var ses in storageEntitySetsAtRiskOfDeletion)
            {
                var cSideObjectsMappedToStorageEntitySetAtRiskOfDeletion =
                    FindMappedConceptualObjects(ses);
                var allCSideObjectsWouldBeDeleted = true;
                foreach (var cSideObject in cSideObjectsMappedToStorageEntitySetAtRiskOfDeletion)
                {
                    if (!allCSideObjectsThatWouldBeDeleted.Contains(cSideObject))
                    {
                        allCSideObjectsWouldBeDeleted = false;
                        break;
                    }
                }
                if (allCSideObjectsWouldBeDeleted)
                {
                    unmappedStorageEntitySets.Add(ses);
                }
            }
            return unmappedStorageEntitySets;
        }
internal static ICollection < StorageEntitySet > UnmappedStorageEntitySetsIfDelete ( ICollection < EFElement > elementsToBeDeleted ) { var unmappedStorageEntitySets = new HashSet < StorageEntitySet > ( ) ; if ( null == elementsToBeDeleted ) { Debug . Fail ( " " ) ; return unmappedStorageEntitySets ; } var allCSideObjectsThatWouldBeDeleted = new HashSet < EFObject > ( ) ; var storageEntitySetsAtRiskOfDeletion = new HashSet < StorageEntitySet > ( ) ; foreach ( var elementToBeDeleted in elementsToBeDeleted ) { var cSideObjectsThatWouldBeDeleted = ConceptualObjectsToBeDeleted ( elementToBeDeleted ) ; allCSideObjectsThatWouldBeDeleted . UnionWith ( cSideObjectsThatWouldBeDeleted ) ; storageEntitySetsAtRiskOfDeletion . UnionWith ( FindMappedStorageEntitySets ( cSideObjectsThatWouldBeDeleted ) ) ; } foreach ( var ses in storageEntitySetsAtRiskOfDeletion ) { var cSideObjectsMappedToStorageEntitySetAtRiskOfDeletion = FindMappedConceptualObjects ( ses ) ; var allCSideObjectsWouldBeDeleted = true ; foreach ( var cSideObject in cSideObjectsMappedToStorageEntitySetAtRiskOfDeletion ) { if ( ! allCSideObjectsThatWouldBeDeleted . Contains ( cSideObject ) ) { allCSideObjectsWouldBeDeleted = false ; break ; } } if ( allCSideObjectsWouldBeDeleted ) { unmappedStorageEntitySets . Add ( ses ) ; } } return unmappedStorageEntitySets ; }
constructs the list of StorageEntitySet objects that will be unmapped if the
conceptual EntityTypes are deleted (including all StorageEntitySet objects
which were already unmapped)
constructs the list of StorageEntitySet objects that will be unmapped if the conceptual EntityTypes are deleted ( including all StorageEntitySet objects which were already unmapped )
// construct the list of objects on the C-side that would be deleted if cetToBeDeleted was deleted // and add them to the set of all C-side objects that would be deleted // find set of StorageEntitySets mapped to those C-side objects // loop over the StorageEntitySets in storageEntitySetsAtRiskOfDeletion, // these EntitySets will be in the unmappedStorageEntitySets set unless they are _also_ // mapped to some C-side object not in cSideObjectsThatWouldBeDeleted above // find list of C-side EntityTypes, EntitySets, Associations and AssociationSets // which are mapped to the StorageEntitySet // if all these C-side objects would be deleted then the StorageEntitySet // could also be safely deleted and so is added to unmappedStorageEntitySets
the list of StorageEntitySet objects that will be unmapped if the
conceptual EntityType is deleted
the list of StorageEntitySet objects that will be unmapped if the conceptual EntityType is deleted
elementsToBeDeleted
ICollection<EFElement>
collection of conceptual EFElements being considered for deletion
collection of conceptual EFElements being considered for deletion