// 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 }
static SmiMetaDataPropertyCollection() { EmptyInstance = new SmiMetaDataPropertyCollection(); EmptyInstance.SetReadOnly(); }