Пример #1
0
        private bool ValidatePropertyType(TableDetailsRow row, ICollection<EdmSchemaError> errors)
        {
            string errorMessage = null;

            if (row.IsDataTypeNull())
            {
                errorMessage =
                    string.Format(
                        CultureInfo.InvariantCulture,
                        Resources_VersioningFacade.UnsupportedDataTypeUnknownType,
                        row.ColumnName,
                        row.GetMostQualifiedTableName());
            }
            else
            {
                bool excludedForVersion;
                var propertyType = GetStorePrimitiveTypeForVersion(row.DataType, out excludedForVersion);

                if (propertyType == null)
                {
                    errorMessage =
                        string.Format(
                            CultureInfo.InvariantCulture,
                            excludedForVersion
                                ? Resources_VersioningFacade.UnsupportedDataTypeForTarget
                                : Resources_VersioningFacade.UnsupportedDataType,
                            row.DataType,
                            row.GetMostQualifiedTableName(),
                            row.ColumnName);
                }
            }

            if (errorMessage != null)
            {
                errors.Add(
                    new EdmSchemaError(
                        errorMessage,
                        (int)ModelBuilderErrorCode.UnsupportedType,
                        EdmSchemaErrorSeverity.Warning));
            }

            return errorMessage == null;
        }
Пример #2
0
        private static bool ValidateFacetValueInRange(
            PrimitiveType storePrimitiveType, string facetName, int actualValue, TableDetailsRow row, ICollection<EdmSchemaError> errors)
        {
            Debug.Assert(storePrimitiveType != null, "storePrimitiveType != null");
            Debug.Assert(facetName != null, "facetName != null");
            Debug.Assert(row != null, "row != null");
            Debug.Assert(errors != null, "errors != null");

            var facetDescription = storePrimitiveType.FacetDescriptions.SingleOrDefault(f => f.FacetName == facetName);

            if (facetDescription != null
                && !facetDescription.IsConstant)
            {
                if (actualValue < facetDescription.MinValue
                    || actualValue > facetDescription.MaxValue)
                {
                    errors.Add(
                        new EdmSchemaError(
                            string.Format(
                                CultureInfo.InvariantCulture,
                                Resources_VersioningFacade.ColumnFacetValueOutOfRange,
                                facetName,
                                actualValue,
                                facetDescription.MinValue,
                                facetDescription.MaxValue,
                                row.ColumnName,
                                row.GetMostQualifiedTableName()),
                            (int)ModelBuilderErrorCode.FacetValueOutOfRange,
                            EdmSchemaErrorSeverity.Warning));

                    return false;
                }
            }

            return true;
        }