/// <summary>
        /// Validate that the expected and actual type names and type kinds are compatible.
        /// </summary>
        /// <param name="collectionItemTypeName">The actual type name.</param>
        /// <param name="collectionItemTypeKind">The actual type kind.</param>
        private void ValidateCollectionItemTypeNameAndKind(string collectionItemTypeName, EdmTypeKind collectionItemTypeKind)
        {
            // Compare the item type kinds.
            if (this.itemTypeKind != collectionItemTypeKind)
            {
                throw new ODataException(Strings.CollectionWithoutExpectedTypeValidator_IncompatibleItemTypeKind(collectionItemTypeKind, this.itemTypeKind));
            }

            if (this.itemTypeKind == EdmTypeKind.Primitive)
            {
                Debug.Assert(this.primitiveItemType != null, "this.primitiveItemType != null");
                Debug.Assert(collectionItemTypeName != null, "collectionItemTypeName != null");

                // NOTE: we do support type inheritance for spatial primitive types; otherwise the type names have to match.
                if (string.CompareOrdinal(this.itemTypeName, collectionItemTypeName) == 0)
                {
                    return;
                }

                if (this.primitiveItemType.IsSpatial())
                {
                    EdmPrimitiveTypeKind collectionItemPrimitiveKind = EdmCoreModel.Instance.GetPrimitiveTypeKind(collectionItemTypeName);
                    IEdmPrimitiveType    collectionItemPrimitiveType = EdmCoreModel.Instance.GetPrimitiveType(collectionItemPrimitiveKind);

                    if (this.itemTypeDerivedFromCollectionValue)
                    {
                        // If the collection defines an item type, the collection item type has to be assignable to it.
                        if (this.primitiveItemType.IsAssignableFrom(collectionItemPrimitiveType))
                        {
                            return;
                        }
                    }
                    else
                    {
                        // If the collection does not define an item type, the collection items must have a common base type.
                        IEdmPrimitiveType commonBaseType = EdmLibraryExtensions.GetCommonBaseType(this.primitiveItemType, collectionItemPrimitiveType);
                        if (commonBaseType != null)
                        {
                            this.primitiveItemType = commonBaseType;
                            this.itemTypeName      = commonBaseType.ODataFullName();
                            return;
                        }
                    }
                }

                throw new ODataException(Strings.CollectionWithoutExpectedTypeValidator_IncompatibleItemTypeName(collectionItemTypeName, this.itemTypeName));
            }
            else
            {
                // Since we do not support type inheritance for complex types, comparison of the type names is sufficient
                if (string.CompareOrdinal(this.itemTypeName, collectionItemTypeName) != 0)
                {
                    throw new ODataException(Strings.CollectionWithoutExpectedTypeValidator_IncompatibleItemTypeName(collectionItemTypeName, this.itemTypeName));
                }
            }
        }