src/Misc/EFTools/EntityDesignModel/Commands/UpdateConceptualAndMappingModelsCommand.cs
/// <summary>
///     Construct the list of those EntityTypes in tempArtifactModel
///     which are "new" compared to the existing model where "new"
///     is defined by mapping to a set of DatabaseObjects (representing
///     tables/views on the database) which did not exist in the
///     existing model
/// </summary>
Construct the list of those EntityTypes in tempArtifactModel
which are "new" compared to the existing model where "new"
is defined by mapping to a set of DatabaseObjects (representing
tables/views on the database) which did not exist in the
existing model
Construct the list of those EntityTypes in tempArtifactModel which are " new " compared to the existing model where " new " is defined by mapping to a set of DatabaseObjects ( representing tables / views on the database ) which did not exist in the existing model
private void FindNewAndExistingEntityTypes(
            out HashSet<EntityType> newEntityTypes, out HashSet<EntityType> existingEntityTypes)
        {
            newEntityTypes = new HashSet<EntityType>();
            existingEntityTypes = new HashSet<EntityType>();
            if (null == _modelRepresentingDatabase
                || null == _modelRepresentingDatabase.Artifact
                || null == _modelRepresentingDatabase.Artifact.ConceptualModel())
            {
                return;
            }
            var allPreExistingTablesAndViews =
                _preExistingModel.AllTablesAndViews;
            foreach (var et in _modelRepresentingDatabase.Artifact.ConceptualModel().EntityTypes())
            {
                var entityTypeIdentity =
                    _modelRepresentingDatabase.GetEntityTypeIdentityForEntityType(et);
                if (null == entityTypeIdentity
                    || entityTypeIdentity.Count == 0)
                {
                    newEntityTypes.Add(et);
                }
                else
                {
                    var matchesPreExistingTableOrView = false;
                    foreach (var tableOrView in entityTypeIdentity.TablesAndViews)
                    {
                        if (allPreExistingTablesAndViews.Contains(tableOrView))
                        {
                            matchesPreExistingTableOrView = true;
                            break;
                        }
                    }
                    if (matchesPreExistingTableOrView)
                    {
                        existingEntityTypes.Add(et);
                    }
                    else
                    {
                        newEntityTypes.Add(et);
                    }
                }
            }
        }
private void FindNewAndExistingEntityTypes ( out HashSet < EntityType > newEntityTypes , out HashSet < EntityType > existingEntityTypes ) { newEntityTypes = new HashSet < EntityType > ( ) ; existingEntityTypes = new HashSet < EntityType > ( ) ; if ( null == _modelRepresentingDatabase || null == _modelRepresentingDatabase . Artifact || null == _modelRepresentingDatabase . Artifact . ConceptualModel ( ) ) { return ; } var allPreExistingTablesAndViews = _preExistingModel . AllTablesAndViews ; foreach ( var et in _modelRepresentingDatabase . Artifact . ConceptualModel ( ) . EntityTypes ( ) ) { var entityTypeIdentity = _modelRepresentingDatabase . GetEntityTypeIdentityForEntityType ( et ) ; if ( null == entityTypeIdentity || entityTypeIdentity . Count == 0 ) { newEntityTypes . Add ( et ) ; } else { var matchesPreExistingTableOrView = false ; foreach ( var tableOrView in entityTypeIdentity . TablesAndViews ) { if ( allPreExistingTablesAndViews . Contains ( tableOrView ) ) { matchesPreExistingTableOrView = true ; break ; } } if ( matchesPreExistingTableOrView ) { existingEntityTypes . Add ( et ) ; } else { newEntityTypes . Add ( et ) ; } } } }
Construct the list of those EntityTypes in tempArtifactModel
which are "new" compared to the existing model where "new"
is defined by mapping to a set of DatabaseObjects (representing
tables/views on the database) which did not exist in the
existing model
Construct the list of those EntityTypes in tempArtifactModel which are " new " compared to the existing model where " new " is defined by mapping to a set of DatabaseObjects ( representing tables / views on the database ) which did not exist in the existing model
// find all tables/views in the pre-existing model // loop over each EntityType in the temp model from DB, lookup // its mapped S-side EntitySet (if any) and compare to pre-existing // EntitySets from existing model. Assign the EntityType to either // newEntityTypes or existingEntityTypes based on this
HashSet<EntityType>
out