src/Misc/EFTools/EntityDesignDatabaseGeneration/MetadataWorkspaceExtensions.cs
// <summary>
//     This method will attempt to figure out if the given EntityType is an ancestor. It will return a list of ancestors:
//     1. If the given EntityType is an ancestor, a list of ancestors up to and including the EntityType
//     2. If the given EntityType is not an ancestor, all the ancestors up to the root
// </summary>
// <param name="entityType">The EntityType.</param>
// <param name="rootType">The type of which to check whether this EntityType is an ancestor.</param>
// <param name="selfAndAncestors">The list of ancestors.</param>
// <returns>true if the given EntityType is an ancestor; otherwise, false.</returns>
This method will attempt to figure out if the given EntityType is an ancestor. It will return a list of ancestors:
1. If the given EntityType is an ancestor, a list of ancestors up to and including the EntityType
2. If the given EntityType is not an ancestor, all the ancestors up to the root
This method will attempt to figure out if the given EntityType is an ancestor . It will return a list of ancestors : 1 . If the given EntityType is an ancestor a list of ancestors up to and including the EntityType 2 . If the given EntityType is not an ancestor all the ancestors up to the root
private static bool IsDerivedTypeOf(this EntityType entityType, EntityType rootType, out IList<EntityType> selfAndAncestors)
        {
            selfAndAncestors = new List<EntityType>();
            selfAndAncestors.Add(entityType);
            var baseType = entityType.BaseType as EntityType;
            var foundMatchingAncestor = false;
            while (baseType != null)
            {
                if (baseType == rootType)
                {
                    foundMatchingAncestor = true;
                    break;
                }
                selfAndAncestors.Add(baseType);
                baseType = baseType.BaseType as EntityType;
            }
            return foundMatchingAncestor;
        }
private static bool IsDerivedTypeOf ( this EntityType entityType , EntityType rootType , out IList < EntityType > selfAndAncestors ) { selfAndAncestors = new List < EntityType > ( ) ; selfAndAncestors . Add ( entityType ) ; var baseType = entityType . BaseType as EntityType ; var foundMatchingAncestor = false ; while ( baseType != null ) { if ( baseType == rootType ) { foundMatchingAncestor = true ; break ; } selfAndAncestors . Add ( baseType ) ; baseType = baseType . BaseType as EntityType ; } return foundMatchingAncestor ; }
This method will attempt to figure out if the given EntityType is an ancestor.
This method will attempt to figure out if the given EntityType is an ancestor .
true if the given EntityType is an ancestor; otherwise, false.
true if the given EntityType is an ancestor ; otherwise false .
EntityType
this
rootType
EntityType
The type of which to check whether this EntityType is an ancestor.
The type of which to check whether this EntityType is an ancestor .
IList<EntityType>
out
entityType
None
selfAndAncestors
The list of ancestors.
The list of ancestors .