2 // System.Data.SqlClient.SqlBulkCopyColumnMapping.cs
5 // Umadevi S <sumadevi@novell.com>
9 // Copyright (C) 2004 Novell, Inc (http://www.novell.com)
11 // Permission is hereby granted, free of charge, to any person obtaining
12 // a copy of this software and associated documentation files (the
13 // "Software"), to deal in the Software without restriction, including
14 // without limitation the rights to use, copy, modify, merge, publish,
15 // distribute, sublicense, and/or sell copies of the Software, and to
16 // permit persons to whom the Software is furnished to do so, subject to
17 // the following conditions:
19 // The above copyright notice and this permission notice shall be
20 // included in all copies or substantial portions of the Software.
22 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
23 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
24 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
25 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
26 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
27 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
28 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
31 namespace System.Data.SqlClient
34 /// Class that defines the mapping between a column in the destination table and an
35 /// column in the datasource of SqlBulkCopy's instance
38 public sealed class SqlBulkCopyColumnMapping {
42 int sourceOrdinal = -1;
43 int destinationOrdinal = -1;
44 string sourceColumn = null;
45 string destinationColumn = null;
51 public SqlBulkCopyColumnMapping() {
54 public SqlBulkCopyColumnMapping(int sourceColumnOrdinal, int destinationOrdinal){
55 SourceOrdinal = sourceColumnOrdinal;
56 DestinationOrdinal = destinationOrdinal;
59 public SqlBulkCopyColumnMapping(int sourceColumnOrdinal, string destinationColumn){
60 SourceOrdinal = sourceColumnOrdinal;
61 DestinationColumn = destinationColumn;
64 public SqlBulkCopyColumnMapping(string sourceColumn, int destinationOrdinal){
65 SourceColumn = sourceColumn;
66 DestinationOrdinal = destinationOrdinal;
69 public SqlBulkCopyColumnMapping(string sourceColumn, string destinationColumn){
70 SourceColumn = sourceColumn;
71 DestinationColumn = destinationColumn;
74 # endregion //Constructors
78 public String DestinationColumn {
80 if (this.destinationColumn != null)
81 return destinationColumn;
83 return string.Empty; //ms:doesnot return null.
86 // ms: whenever the name is set the ordinal is reset to -1
87 this.destinationOrdinal = -1;
88 this.destinationColumn = value;
92 public String SourceColumn {
94 if (this.sourceColumn != null)
97 return string.Empty;//ms doesnot return null
100 // ms: whenever the name is set the ordinal is reset to -1
101 this.sourceOrdinal = -1;
102 this.sourceColumn = value;
106 public int DestinationOrdinal {
108 return this.destinationOrdinal;
111 // ms: whenever the ordinal is set, the name is null
113 throw new IndexOutOfRangeException ();
114 this.destinationColumn = null;
115 this.destinationOrdinal = value;
119 public int SourceOrdinal {
121 return this.sourceOrdinal;
124 // ms: whenever the ordinal is set, the name is null
126 throw new IndexOutOfRangeException ();
127 this.sourceColumn = null;
128 this.sourceOrdinal = value;
132 #endregion //Properties