SqlBulkCopyColumnMapping.cs source code in C# .NET

Source code for the .NET framework in C#

                        

Code:

/ FX-1434 / FX-1434 / 1.0 / untmp / whidbey / REDBITS / ndp / fx / src / Data / System / Data / SqlClient / SqlBulkCopyColumnMapping.cs / 1 / SqlBulkCopyColumnMapping.cs

                            //------------------------------------------------------------------------------ 
// 
//     Copyright (c) Microsoft Corporation.  All rights reserved.
// 
// [....] 
// [....]
//----------------------------------------------------------------------------- 
 
// Todo: rename the file
// Caution! ndp\fx\src\data\netmodule\sources needs to follow this change 

namespace System.Data.SqlClient
{
    using System; 
    using System.Data;
    using System.Data.Common; 
    using System.Data.SqlTypes; 
    using System.ComponentModel;
 
    using System.Collections;
    using System.Diagnostics;

    // ------------------------------------------------------------------------------------------------- 
    // this class helps allows the user to create association between source- and targetcolumns
    // 
    // 

#if WINFSInternalOnly 
    internal
#else
    public
#endif 
    sealed class SqlBulkCopyColumnMapping {
        internal string         _destinationColumnName; 
        internal int            _destinationColumnOrdinal; 
        internal string         _sourceColumnName;
        internal int            _sourceColumnOrdinal; 

        // devnote: we don't want the user to detect the columnordinal after WriteToServer call.
        // _sourceColumnOrdinal(s) will be copied to _internalSourceColumnOrdinal when WriteToServer executes.
        internal int            _internalDestinationColumnOrdinal; 
        internal int            _internalSourceColumnOrdinal;   // -1 indicates an undetermined value
 
        public string DestinationColumn { 
            get {
                if (_destinationColumnName != null) { 
                    return _destinationColumnName;
                }
                return string.Empty;
            } 
            set {
                _destinationColumnOrdinal = _internalDestinationColumnOrdinal = -1; 
                _destinationColumnName = value; 
            }
        } 

        public int DestinationOrdinal {
            get {
                    return _destinationColumnOrdinal; 
            }
            set { 
                if (value >= 0) { 
                    _destinationColumnName = null;
                    _destinationColumnOrdinal = _internalDestinationColumnOrdinal = value; 
                }
                else {
                    throw ADP.IndexOutOfRange(value);
                } 
            }
        } 
 
        public string SourceColumn {
            get { 
                if (_sourceColumnName != null) {
                    return _sourceColumnName;
                }
                return string.Empty; 
            }
            set { 
                _sourceColumnOrdinal = _internalSourceColumnOrdinal = -1; 
                _sourceColumnName = value;
            } 
        }

        public int SourceOrdinal {
            get { 
                    return _sourceColumnOrdinal;
            } 
            set { 
                if (value >= 0) {
                    _sourceColumnName = null; 
                    _sourceColumnOrdinal = _internalSourceColumnOrdinal = value;
                }
                else {
                    throw ADP.IndexOutOfRange(value); 
                }
            } 
        } 

        public SqlBulkCopyColumnMapping () { 
            _internalSourceColumnOrdinal = -1;
        }

        public SqlBulkCopyColumnMapping (string sourceColumn, string destinationColumn) { 
            SourceColumn = sourceColumn;
            DestinationColumn = destinationColumn; 
        } 

        public SqlBulkCopyColumnMapping (int sourceColumnOrdinal, string destinationColumn) { 
            SourceOrdinal = sourceColumnOrdinal;
            DestinationColumn = destinationColumn;
        }
 
        public SqlBulkCopyColumnMapping (string sourceColumn, int destinationOrdinal) {
            SourceColumn = sourceColumn; 
            DestinationOrdinal = destinationOrdinal; 
        }
 
        public SqlBulkCopyColumnMapping (int sourceColumnOrdinal, int destinationOrdinal) {
            SourceOrdinal = sourceColumnOrdinal;
            DestinationOrdinal = destinationOrdinal;
        } 
    }
} 

// File provided for Reference Use Only by Microsoft Corporation (c) 2007.
// Copyright (c) Microsoft Corporation. All rights reserved.
                        

Link Menu

Network programming in C#, Network Programming in VB.NET, Network Programming in .NET
This book is available now!
Buy at Amazon US or
Buy at Amazon UK