Beispiel #1
0
        /// <summary>
        /// Handler for the InlineType element
        /// </summary>
        /// <param name="reader">xml reader currently positioned at InlineType element</param>
        private void HandleInlineTypeElement(XmlReader reader)
        {
            Debug.Assert(reader != null);

            SchemaComplexType complexType = new SchemaComplexType(this);

            complexType.Parse(reader);

            TryAddType(complexType, true /*doNotAddErrorForEmptyName*/);
        }
Beispiel #2
0
        /// <summary>
        /// Handler for the InlineType element
        /// </summary>
        /// <param name="reader">xml reader currently positioned at InlineType element</param>
        private void HandleInlineTypeElement(XmlReader reader)
        {
            Debug.Assert(reader != null);

            SchemaComplexType complexType = new SchemaComplexType(this);

            complexType.Parse(reader);

            TryAddType(complexType, true/*doNotAddErrorForEmptyName*/);
        }
        /// <summary>
        /// validate the following negative scenarios:
        /// ReturnType="Collection(EntityTypeA)"
        /// ReturnType="Collection(EntityTypeA)" EntitySet="ESet.EType is not oftype EntityTypeA"
        /// EntitySet="A"
        /// ReturnType="Collection(ComplexTypeA)" EntitySet="something"
        /// ReturnType="Collection(ComplexTypeA)", but the ComplexTypeA has a nested complexType property, this scenario will be handle in the runtime
        /// </summary>
        private void ValidateFunctionImportReturnType(SchemaElement owner, SchemaType returnType, EntityContainerEntitySet entitySet, bool entitySetPathDefined)
        {
            // If entity type, verify specification of entity set and that the type is appropriate for the entity set
            SchemaEntityType entityType = returnType as SchemaEntityType;

            if (entitySet != null && entitySetPathDefined)
            {
                owner.AddError(ErrorCode.FunctionImportEntitySetAndEntitySetPathDeclared,
                               EdmSchemaErrorSeverity.Error,
                               Strings.FunctionImportEntitySetAndEntitySetPathDeclared(this.FQName));
            }

            if (null != entityType)
            {
                // entity type
                if (null == entitySet)
                {
                    // ReturnType="Collection(EntityTypeA)"
                    owner.AddError(ErrorCode.FunctionImportReturnsEntitiesButDoesNotSpecifyEntitySet,
                                   EdmSchemaErrorSeverity.Error,
                                   System.Data.Entity.Strings.FunctionImportReturnEntitiesButDoesNotSpecifyEntitySet(this.FQName));
                }
                else if (null != entitySet.EntityType && !entityType.IsOfType(entitySet.EntityType))
                {
                    // ReturnType="Collection(EntityTypeA)" EntitySet="ESet.EType is not oftype EntityTypeA"
                    owner.AddError(ErrorCode.FunctionImportEntityTypeDoesNotMatchEntitySet,
                                   EdmSchemaErrorSeverity.Error,
                                   System.Data.Entity.Strings.FunctionImportEntityTypeDoesNotMatchEntitySet(
                                       this.FQName, entitySet.EntityType.FQName, entitySet.Name));
                }
            }
            else
            {
                // complex type
                SchemaComplexType complexType = returnType as SchemaComplexType;
                if (complexType != null)
                {
                    if (entitySet != null || entitySetPathDefined)
                    {
                        // ReturnType="Collection(ComplexTypeA)" EntitySet="something"
                        owner.AddError(
                            ErrorCode.ComplexTypeAsReturnTypeAndDefinedEntitySet,
                            EdmSchemaErrorSeverity.Error,
                            owner.LineNumber,
                            owner.LinePosition,
                            System.Data.Entity.Strings.ComplexTypeAsReturnTypeAndDefinedEntitySet(this.FQName, complexType.Name));
                    }
                }
                else
                {
                    Debug.Assert(returnType == null || returnType is ScalarType || returnType is SchemaEnumType || returnType is Relationship,
                                 "null return type, scalar return type, enum return type or relationship expected here.");

                    // scalar type or no return type
                    if (entitySet != null || entitySetPathDefined)
                    {
                        // EntitySet="A"
                        owner.AddError(ErrorCode.FunctionImportSpecifiesEntitySetButDoesNotReturnEntityType,
                                       EdmSchemaErrorSeverity.Error,
                                       System.Data.Entity.Strings.FunctionImportSpecifiesEntitySetButNotEntityType(this.FQName));
                    }
                }
            }
        }