src/Shared/EntityFramework/Core/Objects/ObjectViewFactory.cs
// <summary>
// Determine CLR Type to be exposed for data binding using the supplied EDM item type.
// </summary>
// <typeparam name="TElement"> CLR element type declared by the caller. There is no requirement that this method return the same type, or a type compatible with the declared type; it is merely a suggestion as to which type might be used. </typeparam>
// <param name="ospaceEdmType"> The EDM O-Space type of the items in a particular query result. </param>
// <returns>
// <see cref="Type" /> instance that represents the CLR type that corresponds to the supplied EDM item type; or null if the EDM type does not map to a CLR type. Null is returned in the case where
// <paramref
//     name="ospaceEdmType" />
// is a <see cref="RowType" /> , and no CLR type mapping is specified in the RowType metadata.
// </returns>
Determine CLR Type to be exposed for data binding using the supplied EDM item type.
Determine CLR Type to be exposed for data binding using the supplied EDM item type .
private static Type GetClrType<TElement>(EdmType ospaceEdmType)
        {
            Type clrType;
             However, if the RowType has InitializerMetadata with a non-null CLR Type, 
             that CLR type should be used to determine the properties available for binding.
            if (ospaceEdmType.BuiltInTypeKind
                == BuiltInTypeKind.RowType)
            {
                var itemRowType = (RowType)ospaceEdmType;
                if (itemRowType.InitializerMetadata != null
                    && itemRowType.InitializerMetadata.ClrType != null)
                {
                    clrType = itemRowType.InitializerMetadata.ClrType;
                }
                else
                {
                     If the generic parameter TElement is not exactly a data record type or object type,
                     use it as the CLR type.
                    var elementType = typeof(TElement);
                    if (typeof(IDataRecord).IsAssignableFrom(elementType)
                        || elementType == typeof(object))
                    {
                         No CLR type mapping exists for this RowType.
                        clrType = null;
                    }
                    else
                    {
                        clrType = typeof(TElement);
                    }
                }
            }
            else
            {
                clrType = ospaceEdmType.ClrType;
                 If the CLR type cannot be determined from the EDM type,
                 fallback to the element type declared by the caller.
                if (clrType == null)
                {
                    clrType = typeof(TElement);
                }
            }
            return clrType;
        }
private static Type GetClrType < TElement > ( EdmType ospaceEdmType ) { Type clrType ; if ( ospaceEdmType . BuiltInTypeKind == BuiltInTypeKind . RowType ) { var itemRowType = ( RowType ) ospaceEdmType ; if ( itemRowType . InitializerMetadata != null && itemRowType . InitializerMetadata . ClrType != null ) { clrType = itemRowType . InitializerMetadata . ClrType ; } else { var elementType = typeof ( TElement ) ; if ( typeof ( IDataRecord ) . IsAssignableFrom ( elementType ) || elementType == typeof ( object ) ) { clrType = null ; } else { clrType = typeof ( TElement ) ; } } } else { clrType = ospaceEdmType . ClrType ; if ( clrType == null ) { clrType = typeof ( TElement ) ; } } return clrType ; }
Determine CLR Type to be exposed for data binding using the supplied EDM item type.
Determine CLR Type to be exposed for data binding using the supplied EDM item type .
// EDM RowTypes are generally represented by CLR MaterializedDataRecord types // that need special handling to properly expose the properties available for binding (using ICustomTypeDescriptor and ITypedList implementations, for example). // // However, if the RowType has InitializerMetadata with a non-null CLR Type,  // that CLR type should be used to determine the properties available for binding. // If the generic parameter TElement is not exactly a data record type or object type, // use it as the CLR type. // No CLR type mapping exists for this RowType. // If the CLR type cannot be determined from the EDM type, // fallback to the element type declared by the caller.
instance that represents the CLR type that corresponds to the supplied EDM item type; or null if the EDM type does not map to a CLR type. Null is returned in the case where


instance that represents the CLR type that corresponds to the supplied EDM item type ; or null if the EDM type does not map to a CLR type . Null is returned in the case where
ospaceEdmType
EdmType
The EDM O-Space type of the items in a particular query result.
The EDM O - Space type of the items in a particular query result .
typeparam
CLR element type declared by the caller. There is no requirement that this method return the same type, or a type compatible with the declared type; it is merely a suggestion as to which type might be used.
CLR element type declared by the caller . There is no requirement that this method return the same type or a type compatible with the declared type ; it is merely a suggestion as to which type might be used .