* SqlException.cs: Modified HResult/ErrorCode to match MS. Removed
[mono.git] / mcs / class / System.Data / System.Data.SqlClient / SqlBulkCopyColumnMapping.cs
1 //
2 // System.Data.SqlClient.SqlBulkCopyColumnMapping.cs
3 //
4 // Author:
5 //   Umadevi S <sumadevi@novell.com>
6 //
7
8 //
9 // Copyright (C) 2004 Novell, Inc (http://www.novell.com)
10 //
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:
18 // 
19 // The above copyright notice and this permission notice shall be
20 // included in all copies or substantial portions of the Software.
21 // 
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.
29 //
30
31 #if NET_2_0
32 namespace System.Data.SqlClient
33 {
34         /// <summary>
35         /// Class that defines the mapping between a column in the destination table and an
36         /// column in the datasource of SqlBulkCopy's instance
37         /// </summary>
38         
39         public sealed class SqlBulkCopyColumnMapping {
40
41         #region Fields
42         
43         int sourceOrdinal = -1;
44         int destinationOrdinal = -1;
45         string sourceColumn = null;
46         string destinationColumn = null;
47
48         #endregion //Fields
49
50         #region Constructors
51         
52         public SqlBulkCopyColumnMapping() {
53         }
54         
55         public SqlBulkCopyColumnMapping(int sourceColumnOrdinal, int destinationOrdinal){
56                 SourceOrdinal = sourceColumnOrdinal;
57                 DestinationOrdinal = destinationOrdinal;
58         }
59
60         public SqlBulkCopyColumnMapping(int sourceColumnOrdinal, string destinationColumn){
61                 SourceOrdinal = sourceColumnOrdinal;
62                 DestinationColumn = destinationColumn;  
63         }
64
65         public SqlBulkCopyColumnMapping(string sourceColumn, int destinationOrdinal){
66                 SourceColumn = sourceColumn;            
67                 DestinationOrdinal = destinationOrdinal;
68         }
69
70         public SqlBulkCopyColumnMapping(string sourceColumn, string destinationColumn){
71                 SourceColumn = sourceColumn;
72                 DestinationColumn = destinationColumn;
73         }
74
75         # endregion //Constructors      
76
77         # region Properties
78         
79         public String DestinationColumn {
80                 get {
81                         if (this.destinationColumn != null)
82                                 return destinationColumn;
83                         else
84                                 return string.Empty; //ms:doesnot return null.
85                 }
86                 set {
87                         // ms: whenever the name is set the ordinal is reset to -1
88                         this.destinationOrdinal = -1;
89                         this.destinationColumn = value;
90                 }
91         }
92         
93         public String SourceColumn {
94                 get {
95                         if (this.sourceColumn != null)
96                                 return sourceColumn;
97                         else
98                                 return string.Empty;//ms doesnot return null
99                 }
100                 set {
101                         // ms: whenever the name is set the ordinal is reset to -1
102                         this.sourceOrdinal = -1;
103                         this.sourceColumn = value;
104                 }
105         }
106
107         public int DestinationOrdinal {
108                 get {
109                          return this.destinationOrdinal;
110                 }
111                 set {
112                         // ms: whenever the ordinal is set, the name is null
113                         if (value < 0)
114                                 throw new IndexOutOfRangeException ();
115                         this.destinationColumn = null;
116                         this.destinationOrdinal =  value;
117                 }
118         }
119         
120         public int SourceOrdinal {
121                 get {
122                          return this.sourceOrdinal;
123                 }
124                 set {
125                         // ms: whenever the ordinal is set, the name is null
126                         if (value < 0)
127                                 throw new IndexOutOfRangeException ();
128                         this.sourceColumn = null;
129                         this.sourceOrdinal =  value;
130                 }
131         }
132
133         #endregion //Properties 
134
135         }
136 }
137
138 #endif