Example #1
0
        // SMI V220 ctor.
        internal SmiExtendedMetaData(
            SqlDbType dbType,
            long maxLength,
            byte precision,
            byte scale,
            long localeId,
            SqlCompareOptions compareOptions,
            string udtAssemblyQualifiedName,
            bool isMultiValued,
            IList <SmiExtendedMetaData> fieldMetaData,
            SmiMetaDataPropertyCollection extendedProperties,
            string name,
            string typeSpecificNamePart1,
            string typeSpecificNamePart2,
            string typeSpecificNamePart3) :
            base(dbType,
                 maxLength,
                 precision,
                 scale,
                 localeId,
                 compareOptions,
                 udtAssemblyQualifiedName,
                 isMultiValued,
                 fieldMetaData,
                 extendedProperties)
        {
            Debug.Assert(null == name || MaxNameLength >= name.Length, "Name is too long");

            _name = name;
            _typeSpecificNamePart1 = typeSpecificNamePart1;
            _typeSpecificNamePart2 = typeSpecificNamePart2;
            _typeSpecificNamePart3 = typeSpecificNamePart3;
        }
Example #2
0
 // SMI V220 ctor.
 internal SmiQueryMetaData(SqlDbType dbType,
                           long maxLength,
                           byte precision,
                           byte scale,
                           long localeId,
                           SqlCompareOptions compareOptions,
                           bool isMultiValued,
                           IList <SmiExtendedMetaData> fieldMetaData,
                           SmiMetaDataPropertyCollection extendedProperties,
                           string name,
                           string typeSpecificNamePart1,
                           string typeSpecificNamePart2,
                           string typeSpecificNamePart3,
                           SqlBoolean isKey
                           ) :
     base(dbType,
          maxLength,
          precision,
          scale,
          localeId,
          compareOptions,
          isMultiValued,
          fieldMetaData,
          extendedProperties,
          name,
          typeSpecificNamePart1,
          typeSpecificNamePart2,
          typeSpecificNamePart3,
          isKey
          )
 {
 }
Example #3
0
 // SMI V200 ctor.
 internal SmiParameterMetaData(
     SqlDbType dbType,
     long maxLength,
     byte precision,
     byte scale,
     long localeId,
     SqlCompareOptions compareOptions,
     bool isMultiValued,
     IList <SmiExtendedMetaData> fieldMetaData,
     SmiMetaDataPropertyCollection extendedProperties,
     string name,
     string typeSpecificNamePart1,
     string typeSpecificNamePart2,
     string typeSpecificNamePart3,
     ParameterDirection direction) :
     this(dbType,
          maxLength,
          precision,
          scale,
          localeId,
          compareOptions,
          null,
          isMultiValued,
          fieldMetaData,
          extendedProperties,
          name,
          typeSpecificNamePart1,
          typeSpecificNamePart2,
          typeSpecificNamePart3,
          direction)
 {
 }
Example #4
0
        // Internal setter to be used by constructors only!  Modifies state!
        private void SetDefaultsForType(SqlDbType dbType)
        {
            SmiMetaData smdDflt = GetDefaultForType(dbType);

            _databaseType       = dbType;
            _maxLength          = smdDflt.MaxLength;
            _precision          = smdDflt.Precision;
            _scale              = smdDflt.Scale;
            _localeId           = smdDflt.LocaleId;
            _compareOptions     = smdDflt.CompareOptions;
            _isMultiValued      = smdDflt._isMultiValued;
            _fieldMetaData      = smdDflt._fieldMetaData;       // This is ok due to immutability
            _extendedProperties = smdDflt._extendedProperties;  // This is ok due to immutability
        }
Example #5
0
        // Private constructor used only to initialize default instance array elements.
        // DO NOT EXPOSE OUTSIDE THIS CLASS!
        private SmiMetaData(
            SqlDbType sqlDbType,
            long maxLength,
            byte precision,
            byte scale,
            SqlCompareOptions compareOptions)
        {
            _databaseType   = sqlDbType;
            _maxLength      = maxLength;
            _precision      = precision;
            _scale          = scale;
            _compareOptions = compareOptions;

            // defaults are the same for all types for the following attributes.
            _localeId           = 0;
            _isMultiValued      = false;
            _fieldMetaData      = s_emptyFieldList;
            _extendedProperties = SmiMetaDataPropertyCollection.EmptyInstance;
        }
Example #6
0
 // SMI V200 ctor.
 internal SmiMetaData(
     SqlDbType dbType,
     long maxLength,
     byte precision,
     byte scale,
     long localeId,
     SqlCompareOptions compareOptions,
     bool isMultiValued,
     IList <SmiExtendedMetaData> fieldTypes,
     SmiMetaDataPropertyCollection extendedProperties)
     :
     this(dbType,
          maxLength,
          precision,
          scale,
          localeId,
          compareOptions,
          null,
          isMultiValued,
          fieldTypes,
          extendedProperties)
 {
 }
Example #7
0
 // SMI V220 ctor.
 internal SmiParameterMetaData(
     SqlDbType dbType,
     long maxLength,
     byte precision,
     byte scale,
     long localeId,
     SqlCompareOptions compareOptions,
     string udtAssemblyQualifiedName,
     bool isMultiValued,
     IList <SmiExtendedMetaData> fieldMetaData,
     SmiMetaDataPropertyCollection extendedProperties,
     string name,
     string typeSpecificNamePart1,
     string typeSpecificNamePart2,
     string typeSpecificNamePart3,
     ParameterDirection direction) :
     base(dbType,
          maxLength,
          precision,
          scale,
          localeId,
          compareOptions,
          udtAssemblyQualifiedName,
          isMultiValued,
          fieldMetaData,
          extendedProperties,
          name,
          typeSpecificNamePart1,
          typeSpecificNamePart2,
          typeSpecificNamePart3)
 {
     Debug.Assert(ParameterDirection.Input == direction ||
                  ParameterDirection.Output == direction ||
                  ParameterDirection.InputOutput == direction ||
                  ParameterDirection.ReturnValue == direction, "Invalid direction: " + direction);
     _direction = direction;
 }
Example #8
0
        // SMI V220 ctor.
        internal SmiMetaData(
            SqlDbType dbType,
            long maxLength,
            byte precision,
            byte scale,
            long localeId,
            SqlCompareOptions compareOptions,
            string udtAssemblyQualifiedName,
            bool isMultiValued,
            IList <SmiExtendedMetaData> fieldTypes,
            SmiMetaDataPropertyCollection extendedProperties)
        {
            Debug.Assert(IsSupportedDbType(dbType), "Invalid SqlDbType: " + dbType);

            SetDefaultsForType(dbType);

            switch (dbType)
            {
            case SqlDbType.BigInt:
            case SqlDbType.Bit:
            case SqlDbType.DateTime:
            case SqlDbType.Float:
            case SqlDbType.Image:
            case SqlDbType.Int:
            case SqlDbType.Money:
            case SqlDbType.Real:
            case SqlDbType.SmallDateTime:
            case SqlDbType.SmallInt:
            case SqlDbType.SmallMoney:
            case SqlDbType.Timestamp:
            case SqlDbType.TinyInt:
            case SqlDbType.UniqueIdentifier:
            case SqlDbType.Variant:
            case SqlDbType.Xml:
            case SqlDbType.Date:
                break;

            case SqlDbType.Binary:
            case SqlDbType.VarBinary:
                _maxLength = maxLength;
                break;

            case SqlDbType.Char:
            case SqlDbType.NChar:
            case SqlDbType.NVarChar:
            case SqlDbType.VarChar:
                // locale and compare options are not validated until they get to the server
                _maxLength      = maxLength;
                _localeId       = localeId;
                _compareOptions = compareOptions;
                break;

            case SqlDbType.NText:
            case SqlDbType.Text:
                _localeId       = localeId;
                _compareOptions = compareOptions;
                break;

            case SqlDbType.Decimal:
                Debug.Assert(MinPrecision <= precision && SqlDecimal.MaxPrecision >= precision, "Invalid precision: " + precision);
                Debug.Assert(MinScale <= scale && SqlDecimal.MaxScale >= scale, "Invalid scale: " + scale);
                Debug.Assert(scale <= precision, "Precision: " + precision + " greater than scale: " + scale);
                _precision = precision;
                _scale     = scale;
                _maxLength = s_maxLenFromPrecision[precision - 1];
                break;

            case SqlDbType.Udt:
                throw System.Data.Common.Custom.ADP.DbTypeNotSupported(SqlDbType.Udt.ToString());

            case SqlDbType.Structured:
                if (null != fieldTypes)
                {
                    _fieldMetaData = new System.Collections.ObjectModel.ReadOnlyCollection <SmiExtendedMetaData>(fieldTypes);
                }
                _isMultiValued = isMultiValued;
                _maxLength     = _fieldMetaData.Count;
                break;

            case SqlDbType.Time:
                Debug.Assert(MinScale <= scale && scale <= MaxTimeScale, "Invalid time scale: " + scale);
                _scale     = scale;
                _maxLength = 5 - s_maxVarTimeLenOffsetFromScale[scale];
                break;

            case SqlDbType.DateTime2:
                Debug.Assert(MinScale <= scale && scale <= MaxTimeScale, "Invalid time scale: " + scale);
                _scale     = scale;
                _maxLength = 8 - s_maxVarTimeLenOffsetFromScale[scale];
                break;

            case SqlDbType.DateTimeOffset:
                Debug.Assert(MinScale <= scale && scale <= MaxTimeScale, "Invalid time scale: " + scale);
                _scale     = scale;
                _maxLength = 10 - s_maxVarTimeLenOffsetFromScale[scale];
                break;

            default:
                Debug.Assert(false, "How in the world did we get here? :" + dbType);
                break;
            }

            if (null != extendedProperties)
            {
                extendedProperties.SetReadOnly();
                _extendedProperties = extendedProperties;
            }

            // properties and fields must meet the following conditions at this point:
            //  1) not null
            //  2) read only
            //  3) same number of columns in each list (0 count acceptable for properties that are "unused")
            Debug.Assert(null != _extendedProperties && _extendedProperties.IsReadOnly, "SmiMetaData.ctor: _extendedProperties is " + (null != _extendedProperties ? "writeable" : "null"));
            Debug.Assert(null != _fieldMetaData && _fieldMetaData.IsReadOnly, "SmiMetaData.ctor: _fieldMetaData is " + (null != _fieldMetaData ? "writeable" : "null"));
#if DEBUG
            ((SmiDefaultFieldsProperty)_extendedProperties[SmiPropertySelector.DefaultFields]).CheckCount(_fieldMetaData.Count);
            ((SmiUniqueKeyProperty)_extendedProperties[SmiPropertySelector.UniqueKey]).CheckCount(_fieldMetaData.Count);
#endif
        }
Example #9
0
 static SmiMetaDataPropertyCollection()
 {
     EmptyInstance = new SmiMetaDataPropertyCollection();
     EmptyInstance.SetReadOnly();
 }