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.
32 namespace System
.Data
.SqlClient
35 /// Class that defines the mapping between a column in the destination table and an
36 /// column in the datasource of SqlBulkCopy's instance
39 public sealed class SqlBulkCopyColumnMapping
{
43 int sourceOrdinal
= -1;
44 int destinationOrdinal
= -1;
45 string sourceColumn
= null;
46 string destinationColumn
= null;
52 public SqlBulkCopyColumnMapping() {
55 public SqlBulkCopyColumnMapping(int sourceColumnOrdinal
, int destinationOrdinal
){
56 SourceOrdinal
= sourceColumnOrdinal
;
57 DestinationOrdinal
= destinationOrdinal
;
60 public SqlBulkCopyColumnMapping(int sourceColumnOrdinal
, string destinationColumn
){
61 SourceOrdinal
= sourceColumnOrdinal
;
62 DestinationColumn
= destinationColumn
;
65 public SqlBulkCopyColumnMapping(string sourceColumn
, int destinationOrdinal
){
66 SourceColumn
= sourceColumn
;
67 DestinationOrdinal
= destinationOrdinal
;
70 public SqlBulkCopyColumnMapping(string sourceColumn
, string destinationColumn
){
71 SourceColumn
= sourceColumn
;
72 DestinationColumn
= destinationColumn
;
75 # endregion //Constructors
79 public String DestinationColumn
{
81 if (this.destinationColumn
!= null)
82 return destinationColumn
;
84 return string.Empty
; //ms:doesnot return null.
87 // ms: whenever the name is set the ordinal is reset to -1
88 this.destinationOrdinal
= -1;
89 this.destinationColumn
= value;
93 public String SourceColumn
{
95 if (this.sourceColumn
!= null)
98 return string.Empty
;//ms doesnot return null
101 // ms: whenever the name is set the ordinal is reset to -1
102 this.sourceOrdinal
= -1;
103 this.sourceColumn
= value;
107 public int DestinationOrdinal
{
109 return this.destinationOrdinal
;
112 // ms: whenever the ordinal is set, the name is null
114 throw new IndexOutOfRangeException ();
115 this.destinationColumn
= null;
116 this.destinationOrdinal
= value;
120 public int SourceOrdinal
{
122 return this.sourceOrdinal
;
125 // ms: whenever the ordinal is set, the name is null
127 throw new IndexOutOfRangeException ();
128 this.sourceColumn
= null;
129 this.sourceOrdinal
= value;
133 #endregion //Properties