Ejemplo n.º 1
0
        //  SqlDataRecord public API
        /// <include file='../../../../../../../../doc/snippets/Microsoft.Data.SqlClient.Server/SqlDataRecord.xml' path='docs/members[@name="SqlDataRecord"]/ctor/*' />
        public SqlDataRecord(params SqlMetaData[] metaData)
        {
            // Initial consistency check
            if (null == metaData)
            {
                throw ADP.ArgumentNull(nameof(metaData));
            }

            _columnMetaData    = new SqlMetaData[metaData.Length];
            _columnSmiMetaData = new SmiExtendedMetaData[metaData.Length];
            for (int i = 0; i < _columnSmiMetaData.Length; i++)
            {
                if (null == metaData[i])
                {
                    throw ADP.ArgumentNull($"{nameof(metaData)}[{i}]");
                }
                _columnMetaData[i]    = metaData[i];
                _columnSmiMetaData[i] = MetaDataUtilsSmi.SqlMetaDataToSmiExtendedMetaData(_columnMetaData[i]);
            }

            _eventSink = new SmiEventSink_Default();

            _recordBuffer            = new MemoryRecordBuffer(_columnSmiMetaData);
            _usesStringStorageForXml = true;
            _eventSink.ProcessMessagesAndThrow();
        }
Ejemplo n.º 2
0
        //  SqlDataRecord public API
        /// <include file='../../../../../../../doc/snippets/Microsoft.Data.SqlClient.Server/SqlDataRecord.xml' path='docs/members[@name="SqlDataRecord"]/ctor/*' />
        public SqlDataRecord(params SqlMetaData[] metaData)
        {
            // Initial consistency check
            if (metaData == null)
            {
                throw ADP.ArgumentNull(nameof(metaData));
            }

            _columnMetaData    = new SqlMetaData[metaData.Length];
            _columnSmiMetaData = new SmiExtendedMetaData[metaData.Length];
#if NETFRAMEWORK
            ulong smiVersion = SmiVersion;
#endif
            for (int i = 0; i < _columnSmiMetaData.Length; i++)
            {
                if (metaData[i] == null)
                {
                    throw ADP.ArgumentNull($"{nameof(metaData)}[{i}]");
                }
                _columnMetaData[i]    = metaData[i];
                _columnSmiMetaData[i] = MetaDataUtilsSmi.SqlMetaDataToSmiExtendedMetaData(_columnMetaData[i]);
#if NETFRAMEWORK
                if (!MetaDataUtilsSmi.IsValidForSmiVersion(_columnSmiMetaData[i], smiVersion))
                {
                    throw ADP.VersionDoesNotSupportDataType(_columnSmiMetaData[i].TypeName);
                }
#endif
            }

            _eventSink = new SmiEventSink_Default();
#if NETFRAMEWORK
            if (InOutOfProcHelper.InProc)
            {
                _recordContext           = SmiContextFactory.Instance.GetCurrentContext();
                _recordBuffer            = _recordContext.CreateRecordBuffer(_columnSmiMetaData, _eventSink);
                _usesStringStorageForXml = false;
            }
            else
            {
                _recordContext           = null;
                _recordBuffer            = new MemoryRecordBuffer(_columnSmiMetaData);
                _usesStringStorageForXml = true;
            }
#else
            _recordBuffer = new MemoryRecordBuffer(_columnSmiMetaData);
            _eventSink.ProcessMessagesAndThrow();
#endif
        }