Exemple #1
0
        /// <summary>
        /// Returns the type of the property on the specified type.
        /// </summary>
        /// <param name="type">The type to look for the property on.</param>
        /// <param name="propertyName">The name of the property to look for.</param>
        /// <returns>The type of the property specified.</returns>
        private static IEdmTypeReference GetPropertyType(IEdmType type, string propertyName)
        {
            Debug.Assert(propertyName != null, "propertyName != null");

            IEdmStructuredType structuredType = type as IEdmStructuredType;
            IEdmProperty       property       = structuredType == null ? null : structuredType.FindProperty(propertyName);

            if (property != null)
            {
                IEdmTypeReference propertyType = property.Type;
                if (propertyType.IsNonEntityCollectionType())
                {
                    throw new ODataException(ODataErrorStrings.EpmSourceTree_CollectionPropertyCannotBeMapped(propertyName, type.ODataFullName()));
                }

                if (propertyType.IsStream())
                {
                    throw new ODataException(ODataErrorStrings.EpmSourceTree_StreamPropertyCannotBeMapped(propertyName, type.ODataFullName()));
                }

                if (propertyType.IsSpatial())
                {
                    throw new ODataException(ODataErrorStrings.EpmSourceTree_SpatialTypeCannotBeMapped(propertyName, type.ODataFullName()));
                }

                return(property.Type);
            }

            if (type != null && !type.IsOpenType())
            {
                throw new ODataException(ODataErrorStrings.EpmSourceTree_MissingPropertyOnType(propertyName, type.ODataFullName()));
            }

            return(null);
        }