public override TypeUsage GetStoreType(TypeUsage typeUsage)
        {
            Debug.Assert(typeUsage != null, "typeUsage != null");
            Debug.Assert(typeUsage.EdmType.BuiltInTypeKind == BuiltInTypeKind.PrimitiveType, "Primitive type expected.");
            Debug.Assert(typeUsage.EdmType.GetDataSpace() == DataSpace.CSpace, "Expected CSpace type.");

            try
            {
                var legacyStoreTypeUsage = _wrappedProviderManifest.GetStoreType(typeUsage.ToLegacyEdmTypeUsage());
                return(ConvertFromLegacyStoreTypeUsage(legacyStoreTypeUsage));
            }
            catch (SystemData.ProviderIncompatibleException exception)
            {
                throw new ProviderIncompatibleException(exception.Message, exception.InnerException);
            }
        }
コード例 #2
0
 public void GetStoreType_returns_correct_default_type_usages_for_all_primitive_types()
 {
     // SqlProvider does not support SByte
     foreach (var legacyEdmPrimitiveType in LegacyEdmPrimitiveTypes.Where(t => t.Key != "SByte"))
     {
         TypeUsageVerificationHelper.VerifyTypeUsagesEquivalent(
             LegacyProviderManifest.GetStoreType(
                 LegacyMetadata.TypeUsage.CreateDefaultTypeUsage(legacyEdmPrimitiveType.Value)),
             ProviderManifestWrapper.GetStoreType(
                 TypeUsage.CreateDefaultTypeUsage(EdmPrimitiveTypes[legacyEdmPrimitiveType.Key])));
     }
 }
コード例 #3
0
        /// <summary>
        ///     Determines if this column is a narrower data type than another column.
        ///     Used to determine if altering the supplied column definition to this definition will result in data loss.
        /// </summary>
        /// <param name = "column">The column to compare to.</param>
        /// <param name = "providerManifest">Details of the database provider being used.</param>
        /// <returns>True if this column is of a narrower data type.</returns>
        public bool IsNarrowerThan(ColumnModel column, DbProviderManifest providerManifest)
        {
            //Contract.Requires(column != null);
            //Contract.Requires(providerManifest != null);

            var typeUsage = providerManifest.GetStoreType(TypeUsage);
            var otherTypeUsage = providerManifest.GetStoreType(column.TypeUsage);

            return (_typeSize[Type] < _typeSize[column.Type])
                   || !(IsUnicode ?? true) && (column.IsUnicode ?? true)
                   || !(IsNullable ?? true) && (column.IsNullable ?? true)
                   || IsNarrowerThan(typeUsage, otherTypeUsage);
        }