// valid for multi-valued types
        internal override void NewElement(SmiEventSink sink)
        {
#if DEBUG
            SkipPossibleDefaultedColumns(ReadyForToken);
            Debug.Assert(ReadyForToken == _currentField, "Not on first or last column!");
#endif

            // For TVP types, write new-row token
            Debug.Assert(_metaData.IsMultiValued, "Unsupported call for single-valued types");
            _stateObj.WriteByte(TdsEnums.TVP_ROW_TOKEN);
#if DEBUG
            _currentField = 0;
#endif
        }
Example #2
0
        // Set value to null
        //  valid for all types
        internal void SetDBNull()
        {
            Debug.Assert(!_plpUnknownSent, "Setting a column to null that we already stated sending!");
            if (_isPlp)
            {
                _stateObj.Parser.WriteUnsignedLong(TdsEnums.SQL_PLP_NULL, _stateObj);
            }
            else
            {
                switch (_metaData.SqlDbType)
                {
                case SqlDbType.BigInt:
                case SqlDbType.Bit:
                case SqlDbType.DateTime:
                case SqlDbType.Decimal:
                case SqlDbType.Float:
                case SqlDbType.Int:
                case SqlDbType.Money:
                case SqlDbType.Real:
                case SqlDbType.UniqueIdentifier:
                case SqlDbType.SmallDateTime:
                case SqlDbType.SmallInt:
                case SqlDbType.SmallMoney:
                case SqlDbType.TinyInt:
                case SqlDbType.Date:
                case SqlDbType.Time:
                case SqlDbType.DateTime2:
                case SqlDbType.DateTimeOffset:
                    _stateObj.WriteByte(TdsEnums.FIXEDNULL);
                    break;

                case SqlDbType.Binary:
                case SqlDbType.Char:
                case SqlDbType.Image:
                case SqlDbType.NChar:
                case SqlDbType.NText:
                case SqlDbType.NVarChar:
                case SqlDbType.Text:
                case SqlDbType.Timestamp:
                case SqlDbType.VarBinary:
                case SqlDbType.VarChar:
                    _stateObj.Parser.WriteShort(TdsEnums.VARNULL, _stateObj);
                    break;

                case SqlDbType.Udt:
                case SqlDbType.Xml:
                    Debug.Fail("PLP-only types shouldn't get to this point. Type: " + _metaData.SqlDbType);
                    break;

                case SqlDbType.Variant:
                    _stateObj.Parser.WriteInt(TdsEnums.FIXEDNULL, _stateObj);
                    break;

                case SqlDbType.Structured:
                    Debug.Fail("Not yet implemented.  Not needed until Structured UDTs");
                    break;

                default:
                    Debug.Fail("Unexpected SqlDbType: " + _metaData.SqlDbType);
                    break;
                }
            }
        }