src/Shared/EntityFramework/Core/Objects/Internal/ObjectFullSpanRewriter.cs
// <summary>
// Retrieves the Entity (result or element) type referenced by the specified TypeUsage, if
// its EdmType is an Entity type or a collection type with an Entity element type.
// </summary>
// <param name="resultType"> The TypeUsage that provides the EdmType to examine </param>
// <param name="entityType"> The referenced Entity (element) type, if present. </param>
// <returns>
// <c>true</c> if the specified <paramref name="resultType" /> is an Entity type or a collection type with an Entity element type; otherwise <c>false</c> .
// </returns>
Retrieves the Entity (result or element) type referenced by the specified TypeUsage, if
its EdmType is an Entity type or a collection type with an Entity element type.
Retrieves the Entity ( result or element ) type referenced by the specified TypeUsage if its EdmType is an Entity type or a collection type with an Entity element type .
private static bool TryGetEntityType(TypeUsage resultType, out EntityType entityType)
        {
            if (BuiltInTypeKind.EntityType
                == resultType.EdmType.BuiltInTypeKind)
            {
                entityType = (EntityType)resultType.EdmType;
                return true;
            }
            else if (BuiltInTypeKind.CollectionType
                     == resultType.EdmType.BuiltInTypeKind)
            {
                var elementType = ((CollectionType)resultType.EdmType).TypeUsage.EdmType;
                if (BuiltInTypeKind.EntityType
                    == elementType.BuiltInTypeKind)
                {
                    entityType = (EntityType)elementType;
                    return true;
                }
            }
            entityType = null;
            return false;
        }
private static bool TryGetEntityType ( TypeUsage resultType , out EntityType entityType ) { if ( BuiltInTypeKind . EntityType == resultType . EdmType . BuiltInTypeKind ) { entityType = ( EntityType ) resultType . EdmType ; return true ; } else if ( BuiltInTypeKind . CollectionType == resultType . EdmType . BuiltInTypeKind ) { var elementType = ( ( CollectionType ) resultType . EdmType ) . TypeUsage . EdmType ; if ( BuiltInTypeKind . EntityType == elementType . BuiltInTypeKind ) { entityType = ( EntityType ) elementType ; return true ; } } entityType = null ; return false ; }
Retrieves the Entity (result or element) type referenced by the specified TypeUsage, if
its EdmType is an Entity type or a collection type with an Entity element type.
Retrieves the Entity ( result or element ) type referenced by the specified TypeUsage if its EdmType is an Entity type or a collection type with an Entity element type .
// If the result type is an Entity, then simply use that type. // If the result type of the query is a collection, attempt to extract // the element type of the collection and determine if it is an Entity type.
true is an Entity type or a collection type with an Entity element type; otherwise false
true is an Entity type or a collection type with an Entity element type ; otherwise false
resultType
TypeUsage
The TypeUsage that provides the EdmType to examine
The TypeUsage that provides the EdmType to examine
EntityType
out
entityType
The referenced Entity (element) type, if present.
The referenced Entity ( element ) type if present .