1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119
|
//------------------------------------------------------------------------------
// <copyright file="SqlBulkCopyColumnMapping.cs" company="Microsoft">
// Copyright (c) Microsoft Corporation. All rights reserved.
// </copyright>
// <owner current="true" primary="true">Microsoft</owner>
// <owner current="true" primary="false">Microsoft</owner>
//------------------------------------------------------------------------------
// 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
//
//
public 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;
}
}
}
|