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.
33 namespace System.Data.SqlClient
36 /// Class that defines the mapping between a column in the destination table and an
37 /// column in the datasource of SqlBulkCopy's instance
40 public sealed class SqlBulkCopyColumnMapping {
44 int sourceOrdinal = 0;
45 int destinationOrdinal = 0;
46 string sourceColumn = null;
47 string destinationColumn = null;
53 public SqlBulkCopyColumnMapping(){
57 public SqlBulkCopyColumnMapping(int sourceColumnOrdinal, int destinationOrdinal){
58 this.sourceOrdinal = sourceColumnOrdinal;
59 this.destinationOrdinal = destinationOrdinal;
62 public SqlBulkCopyColumnMapping(int sourceColumnOrdinal, string destinationColumn){
63 this.sourceOrdinal = sourceColumnOrdinal;
64 this.destinationColumn = destinationColumn;
67 public SqlBulkCopyColumnMapping(string sourceColumn, int destinationOrdinal){
68 this.sourceColumn = sourceColumn;
69 this.destinationOrdinal = destinationOrdinal;
72 public SqlBulkCopyColumnMapping(string sourceColumn, string destinationColumn){
73 this.sourceColumn = sourceColumn;
74 this.destinationColumn = destinationColumn;
77 # endregion //Constructors
81 public String DestinationColumn {
83 if (this.destinationColumn != null)
84 return destinationColumn;
86 return string.Empty; //ms:doesnot return null.
89 // ms: whenever the name is set the ordinal is reset to -1
90 this.destinationOrdinal = -1;
91 this.destinationColumn = value;
95 public String SourceColumn {
97 if (this.sourceColumn != null)
100 return string.Empty;//ms doesnot return null
103 // ms: whenever the name is set the ordinal is reset to -1
104 this.sourceOrdinal = -1;
105 this.sourceColumn = value;
111 public int DestinationOrdinal {
113 return this.destinationOrdinal;
116 // ms: whenever the ordinal is set, the name is null
118 throw new ArgumentOutOfRangeException();
119 this.destinationColumn = null;
120 this.destinationOrdinal = value;
125 public int SourceOrdinal {
127 return this.sourceOrdinal;
130 // ms: whenever the ordinal is set, the name is null
132 throw new ArgumentOutOfRangeException();
133 this.sourceColumn = null;
134 this.sourceOrdinal = value;
139 #endregion //Properties