示例#1
0
 internal override void Validate()
 {
     base.Validate();
     ValidationHelper.ValidateTypeDeclaration((SchemaElement)this, this._type, (SchemaElement)this._typeSubElement);
     ValidationHelper.ValidateFacets((SchemaElement)this, this._type, this._typeUsageBuilder);
     if (this._isRefType)
     {
         ValidationHelper.ValidateRefType((SchemaElement)this, this._type);
     }
     if (this.Schema.DataModel != SchemaDataModelOption.EntityDataModel)
     {
         if (this.Schema.DataModel == SchemaDataModelOption.ProviderManifestModel)
         {
             if (this._type != null && (!(this._type is ScalarType) || this._collectionKind != CollectionKind.None) || this._typeSubElement != null && !(this._typeSubElement.Type is ScalarType))
             {
                 string str = "";
                 if (this._type != null)
                 {
                     str = Function.GetTypeNameForErrorMessage(this._type, this._collectionKind, this._isRefType);
                 }
                 else if (this._typeSubElement != null)
                 {
                     str = this._typeSubElement.FQName;
                 }
                 this.AddError(ErrorCode.FunctionWithNonEdmTypeNotSupported, EdmSchemaErrorSeverity.Error, (SchemaElement)this, (object)Strings.FunctionWithNonEdmPrimitiveTypeNotSupported((object)str, (object)this.ParentElement.FQName));
             }
         }
         else if (this._type != null)
         {
             if (!(this._type is ScalarType) || this._collectionKind != CollectionKind.None)
             {
                 this.AddError(ErrorCode.FunctionWithNonPrimitiveTypeNotSupported, EdmSchemaErrorSeverity.Error, (SchemaElement)this, (object)Strings.FunctionWithNonPrimitiveTypeNotSupported(this._isRefType ? (object)this._unresolvedType : (object)this._type.FQName, (object)this.ParentElement.FQName));
             }
         }
         else if (this._typeSubElement != null && !(this._typeSubElement.Type is ScalarType))
         {
             if (this.Schema.SchemaVersion < 3.0)
             {
                 this.AddError(ErrorCode.FunctionWithNonPrimitiveTypeNotSupported, EdmSchemaErrorSeverity.Error, (SchemaElement)this, (object)Strings.FunctionWithNonPrimitiveTypeNotSupported((object)this._typeSubElement.FQName, (object)this.ParentElement.FQName));
             }
             else
             {
                 CollectionTypeElement typeSubElement = this._typeSubElement as CollectionTypeElement;
                 if (typeSubElement != null)
                 {
                     RowTypeElement subElement = typeSubElement.SubElement as RowTypeElement;
                     if (subElement != null && subElement.Properties.Any <RowTypePropertyElement>((Func <RowTypePropertyElement, bool>)(p => !p.ValidateIsScalar())))
                     {
                         this.AddError(ErrorCode.TVFReturnTypeRowHasNonScalarProperty, EdmSchemaErrorSeverity.Error, (SchemaElement)this, (object)Strings.TVFReturnTypeRowHasNonScalarProperty);
                     }
                 }
             }
         }
     }
     if (this._typeSubElement == null)
     {
         return;
     }
     this._typeSubElement.Validate();
 }
示例#2
0
 internal override void Validate()
 {
     base.Validate();
     ValidationHelper.ValidateFacets((SchemaElement)this, this._type, this._typeUsageBuilder);
     if (!this._isRefType)
     {
         return;
     }
     ValidationHelper.ValidateRefType((SchemaElement)this, this._type);
 }
        internal override void Validate()
        {
            base.Validate();

            ValidationHelper.ValidateFacets(this, _type, _typeUsageBuilder);

            if (_isRefType)
            {
                ValidationHelper.ValidateRefType(this, _type);
            }
        }
示例#4
0
 internal override void Validate()
 {
     base.Validate();
     ValidationHelper.ValidateFacets((SchemaElement)this, this._type, this._typeUsageBuilder);
     ValidationHelper.ValidateTypeDeclaration((SchemaElement)this, this._type, (SchemaElement)this._typeSubElement);
     if (this._isRefType)
     {
         ValidationHelper.ValidateRefType((SchemaElement)this, this._type);
     }
     if (this._typeSubElement == null)
     {
         return;
     }
     this._typeSubElement.Validate();
 }
示例#5
0
        internal override void Validate()
        {
            base.Validate();

            ValidationHelper.ValidateFacets(this, _type, _typeUsageBuilder);
            ValidationHelper.ValidateTypeDeclaration(this, _type, _typeSubElement);

            if (_isRefType)
            {
                ValidationHelper.ValidateRefType(this, _type);
            }

            if (_typeSubElement != null)
            {
                _typeSubElement.Validate();
            }
        }
示例#6
0
 internal override void Validate()
 {
     base.Validate();
     ValidationHelper.ValidateTypeDeclaration((SchemaElement)this, this._type, (SchemaElement)this._typeSubElement);
     if (this.Schema.DataModel != SchemaDataModelOption.EntityDataModel)
     {
         bool isAggregate = this.ParentElement.IsAggregate;
         if (this._type != null && (!(this._type is ScalarType) || !isAggregate && this._collectionKind != CollectionKind.None))
         {
             string str = "";
             if (this._type != null)
             {
                 str = Function.GetTypeNameForErrorMessage(this._type, this._collectionKind, this._isRefType);
             }
             else if (this._typeSubElement != null)
             {
                 str = this._typeSubElement.FQName;
             }
             if (this.Schema.DataModel == SchemaDataModelOption.ProviderManifestModel)
             {
                 this.AddError(ErrorCode.FunctionWithNonEdmTypeNotSupported, EdmSchemaErrorSeverity.Error, (SchemaElement)this, (object)Strings.FunctionWithNonEdmPrimitiveTypeNotSupported((object)str, (object)this.ParentElement.FQName));
                 return;
             }
             this.AddError(ErrorCode.FunctionWithNonPrimitiveTypeNotSupported, EdmSchemaErrorSeverity.Error, (SchemaElement)this, (object)Strings.FunctionWithNonPrimitiveTypeNotSupported((object)str, (object)this.ParentElement.FQName));
             return;
         }
     }
     ValidationHelper.ValidateFacets((SchemaElement)this, this._type, this._typeUsageBuilder);
     if (this._isRefType)
     {
         ValidationHelper.ValidateRefType((SchemaElement)this, this._type);
     }
     if (this._typeSubElement == null)
     {
         return;
     }
     this._typeSubElement.Validate();
 }
示例#7
0
 internal override void Validate()
 {
     base.Validate();
     ValidationHelper.ValidateRefType((SchemaElement)this, this._type);
 }
示例#8
0
        internal override void Validate()
        {
            base.Validate();

            ValidationHelper.ValidateTypeDeclaration(this, _type, _typeSubElement);

            if (Schema.DataModel
                != SchemaDataModelOption.EntityDataModel)
            {
                Debug.Assert(
                    Schema.DataModel == SchemaDataModelOption.ProviderDataModel ||
                    Schema.DataModel == SchemaDataModelOption.ProviderManifestModel, "Unexpected data model");

                var collectionAllowed = ParentElement.IsAggregate;

                // Only scalar parameters are allowed for functions in s-space.
                Debug.Assert(_typeSubElement == null, "Unexpected type subelement inside <Parameter> element.");
                if (_type != null &&
                    (_type is ScalarType == false || (!collectionAllowed && _collectionKind != CollectionKind.None)))
                {
                    var typeName = "";
                    if (_type != null)
                    {
                        typeName = Function.GetTypeNameForErrorMessage(_type, _collectionKind, _isRefType);
                    }
                    else if (_typeSubElement != null)
                    {
                        typeName = _typeSubElement.FQName;
                    }
                    if (Schema.DataModel
                        == SchemaDataModelOption.ProviderManifestModel)
                    {
                        AddError(
                            ErrorCode.FunctionWithNonEdmTypeNotSupported,
                            EdmSchemaErrorSeverity.Error,
                            this,
                            Strings.FunctionWithNonEdmPrimitiveTypeNotSupported(typeName, ParentElement.FQName));
                    }
                    else
                    {
                        AddError(
                            ErrorCode.FunctionWithNonPrimitiveTypeNotSupported,
                            EdmSchemaErrorSeverity.Error,
                            this,
                            Strings.FunctionWithNonPrimitiveTypeNotSupported(typeName, ParentElement.FQName));
                    }
                    return;
                }
            }

            ValidationHelper.ValidateFacets(this, _type, _typeUsageBuilder);

            if (_isRefType)
            {
                ValidationHelper.ValidateRefType(this, _type);
            }

            if (_typeSubElement != null)
            {
                _typeSubElement.Validate();
            }
        }
示例#9
0
        internal override void Validate()
        {
            base.Validate();

            ValidationHelper.ValidateRefType(this, _type);
        }
示例#10
0
        internal override void Validate()
        {
            base.Validate();

            ValidationHelper.ValidateTypeDeclaration(this, _type, _typeSubElement);
            ValidationHelper.ValidateFacets(this, _type, _typeUsageBuilder);
            if (_isRefType)
            {
                ValidationHelper.ValidateRefType(this, _type);
            }

            if (Schema.DataModel
                != SchemaDataModelOption.EntityDataModel)
            {
                Debug.Assert(
                    Schema.DataModel == SchemaDataModelOption.ProviderDataModel ||
                    Schema.DataModel == SchemaDataModelOption.ProviderManifestModel, "Unexpected data model");

                if (Schema.DataModel
                    == SchemaDataModelOption.ProviderManifestModel)
                {
                    // Only scalar return type is allowed for functions in provider manifest.
                    if (_type != null && (_type is ScalarType == false || _collectionKind != CollectionKind.None)
                        ||
                        _typeSubElement != null && _typeSubElement.Type is ScalarType == false)
                    {
                        var typeName = "";
                        if (_type != null)
                        {
                            typeName = Function.GetTypeNameForErrorMessage(_type, _collectionKind, _isRefType);
                        }
                        else if (_typeSubElement != null)
                        {
                            typeName = _typeSubElement.FQName;
                        }
                        AddError(
                            ErrorCode.FunctionWithNonEdmTypeNotSupported,
                            EdmSchemaErrorSeverity.Error,
                            this,
                            Strings.FunctionWithNonEdmPrimitiveTypeNotSupported(typeName, ParentElement.FQName));
                    }
                }
                else // SchemaDataModelOption.ProviderDataModel
                {
                    Debug.Assert(Schema.DataModel == SchemaDataModelOption.ProviderDataModel, "Unexpected data model");

                    // In SSDL, function may only return a primitive type or a collection of rows.
                    if (_type != null)
                    {
                        // It is not possible to define a collection of rows via a type attribute, hence any collection is not allowed.
                        if (_type is ScalarType == false ||
                            _collectionKind != CollectionKind.None)
                        {
                            AddError(
                                ErrorCode.FunctionWithNonPrimitiveTypeNotSupported,
                                EdmSchemaErrorSeverity.Error,
                                this,
                                Strings.FunctionWithNonPrimitiveTypeNotSupported(
                                    _isRefType ? _unresolvedType : _type.FQName, ParentElement.FQName));
                        }
                    }
                    else if (_typeSubElement != null)
                    {
                        if (_typeSubElement.Type is ScalarType == false)
                        {
                            if (Schema.SchemaVersion
                                < XmlConstants.StoreVersionForV3)
                            {
                                // Before V3 provider model functions only supported scalar return types.
                                AddError(
                                    ErrorCode.FunctionWithNonPrimitiveTypeNotSupported,
                                    EdmSchemaErrorSeverity.Error,
                                    this,
                                    Strings.FunctionWithNonPrimitiveTypeNotSupported(_typeSubElement.FQName, ParentElement.FQName));
                            }
                            else
                            {
                                // Starting from V3, TVFs must return collection of rows and row props can be only primitive types.
                                // The "collection of rows" is the only option in SSDL function ReturnType subelement thus it's enforced on the XSD level,
                                // so we can assume it here. The only thing we need to check is the type of the row properties.
                                var collection = _typeSubElement as CollectionTypeElement;
                                Debug.Assert(collection != null, "Can't find <CollectionType> inside TVF <ReturnType> element");
                                if (collection != null)
                                {
                                    var row = collection.SubElement as RowTypeElement;
                                    Debug.Assert(row != null, "Can't find <RowType> inside TVF <ReturnType><CollectionType> element");
                                    if (row != null)
                                    {
                                        if (row.Properties.Any(p => !p.ValidateIsScalar()))
                                        {
                                            AddError(
                                                ErrorCode.TVFReturnTypeRowHasNonScalarProperty,
                                                EdmSchemaErrorSeverity.Error,
                                                this,
                                                Strings.TVFReturnTypeRowHasNonScalarProperty);
                                        }
                                    }
                                }
                            }
                        }
                        // else type is ScalarType which is supported in all version
                    }
                }
            }

            if (_typeSubElement != null)
            {
                _typeSubElement.Validate();
            }
        }