src/Misc/EFTools/EntityDesignModel/Entity/ConceptualEntityType.cs
/// <summary>
///     Recursively find all derived types of an entity type. This keeps track of the derived types it has found
///     so that if we find one that equals one we've found already it throws a cyclic inheritance error. We use a hashset
///     here because Contains() will be a O(1) operation.
/// </summary>
/// <param name="existingDerivedTypes"></param>
Recursively find all derived types of an entity type. This keeps track of the derived types it has found
so that if we find one that equals one we've found already it throws a cyclic inheritance error. We use a hashset
here because Contains() will be a O(1) operation.
Recursively find all derived types of an entity type . This keeps track of the derived types it has found so that if we find one that equals one we ' ve found already it throws a cyclic inheritance error . We use a hashset here because Contains () will be a O ( 1 ) operation .
private void GetSafeDescendantTypesHelper(ref HashSet<ConceptualEntityType> existingDerivedTypes)
        {
            var antiDeps = GetAntiDependenciesOfType<ConceptualEntityType>();
            foreach (var et in antiDeps)
            {
                if (et != null)
                {
                    Debug.Assert(
                        et.BaseType.Target == this, "Why isn't this conceptual entity type the base type of the found derived type?");
                    if (existingDerivedTypes.Contains(et))
                    {
                        ModelHelper.InvalidSchemaError(Resources.CyclicInheritanceHierarchy, et.NormalizedNameExternal);
                    }
                    else
                    {
                        var cet = et;
                        Debug.Assert(cet != null, "entity type wasn't a ConceptualEntityType!");
                        existingDerivedTypes.Add(cet);
                        cet.GetSafeDescendantTypesHelper(ref existingDerivedTypes);
                    }
                }
            }
        }
private void GetSafeDescendantTypesHelper ( ref HashSet < ConceptualEntityType > existingDerivedTypes ) { var antiDeps = GetAntiDependenciesOfType < ConceptualEntityType > ( ) ; foreach ( var et in antiDeps ) { if ( et != null ) { Debug . Assert ( et . BaseType . Target == this , " " ) ; if ( existingDerivedTypes . Contains ( et ) ) { ModelHelper . InvalidSchemaError ( Resources . CyclicInheritanceHierarchy , et . NormalizedNameExternal ) ; } else { var cet = et ; Debug . Assert ( cet != null , " " ) ; existingDerivedTypes . Add ( cet ) ; cet . GetSafeDescendantTypesHelper ( ref existingDerivedTypes ) ; } } } }
Recursively find all derived types of an entity type.
Recursively find all derived types of an entity type .
// TODO: later on we can convert this method to a tree-based look-ahead to trim the O(n) space we use.  // if we've already found the entity type during our previous traversal, throw an error // add the entity type and its derived types
HashSet<ConceptualEntityType>
ref
existingDerivedTypes
None