static private GetTypeNameForErrorMessage ( System.Data.Entity.Core.SchemaObjectModel.SchemaType type, CollectionKind colKind, bool isRef ) : string | ||
type | System.Data.Entity.Core.SchemaObjectModel.SchemaType | |
colKind | CollectionKind | |
isRef | bool | |
return | string |
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(); }
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(); }
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(); } }
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(); } }
internal override void Validate() { base.Validate(); if (this._type != null && this._returnTypeList != null) { this.AddError(ErrorCode.ReturnTypeDeclaredAsAttributeAndElement, EdmSchemaErrorSeverity.Error, (object)Strings.TypeDeclaredAsAttributeAndElement); } if (this._returnTypeList == null && this.Type == null) { if (this.IsComposable) { this.AddError(ErrorCode.ComposableFunctionOrFunctionImportWithoutReturnType, EdmSchemaErrorSeverity.Error, (object)Strings.ComposableFunctionOrFunctionImportMustDeclareReturnType); } } else if (!this.IsComposable && !this.IsFunctionImport) { this.AddError(ErrorCode.NonComposableFunctionWithReturnType, EdmSchemaErrorSeverity.Error, (object)Strings.NonComposableFunctionMustNotDeclareReturnType); } if (this.Schema.DataModel != SchemaDataModelOption.EntityDataModel) { if (this.IsAggregate) { if (this.Parameters.Count != 1) { this.AddError(ErrorCode.InvalidNumberOfParametersForAggregateFunction, EdmSchemaErrorSeverity.Error, (SchemaElement)this, (object)Strings.InvalidNumberOfParametersForAggregateFunction((object)this.FQName)); } else if (this.Parameters.GetElementAt(0).CollectionKind == CollectionKind.None) { this.AddError(ErrorCode.InvalidParameterTypeForAggregateFunction, EdmSchemaErrorSeverity.Error, (SchemaElement)this, (object)Strings.InvalidParameterTypeForAggregateFunction((object)this.Parameters.GetElementAt(0).Name, (object)this.FQName)); } } if (!this.IsComposable && (this.IsAggregate || this.IsNiladicFunction || this.IsBuiltIn)) { this.AddError(ErrorCode.NonComposableFunctionAttributesNotValid, EdmSchemaErrorSeverity.Error, (object)Strings.NonComposableFunctionHasDisallowedAttribute); } if (this.CommandText != null) { if (this.IsComposable) { this.AddError(ErrorCode.ComposableFunctionWithCommandText, EdmSchemaErrorSeverity.Error, (object)Strings.CommandTextFunctionsNotComposable); } if (this.StoreFunctionName != null) { this.AddError(ErrorCode.FunctionDeclaresCommandTextAndStoreFunctionName, EdmSchemaErrorSeverity.Error, (object)Strings.CommandTextFunctionsCannotDeclareStoreFunctionName); } } } if (this.Schema.DataModel == SchemaDataModelOption.ProviderDataModel && this._type != null && (!(this._type is ScalarType) || this._returnTypeCollectionKind != CollectionKind.None)) { this.AddError(ErrorCode.FunctionWithNonPrimitiveTypeNotSupported, EdmSchemaErrorSeverity.Error, (SchemaElement)this, (object)Strings.FunctionWithNonPrimitiveTypeNotSupported((object)Function.GetTypeNameForErrorMessage(this._type, this._returnTypeCollectionKind, this._isRefType), (object)this.FQName)); } if (this._returnTypeList != null) { foreach (SchemaElement returnType in this._returnTypeList) { returnType.Validate(); } } if (this._parameters != null) { foreach (SchemaElement parameter in this._parameters) { parameter.Validate(); } } if (this._commandText == null) { return; } this._commandText.Validate(); }