Merge pull request #2655 from ludovic-henry/fix-wait-timeout
[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 namespace System.Data.SqlClient
32 {
33         /// <summary>
34         /// Class that defines the mapping between a column in the destination table and an
35         /// column in the datasource of SqlBulkCopy's instance
36         /// </summary>
37         
38         public sealed class SqlBulkCopyColumnMapping {
39
40         #region Fields
41         
42         int sourceOrdinal = -1;
43         int destinationOrdinal = -1;
44         string sourceColumn = null;
45         string destinationColumn = null;
46
47         #endregion //Fields
48
49         #region Constructors
50         
51         public SqlBulkCopyColumnMapping() {
52         }
53         
54         public SqlBulkCopyColumnMapping(int sourceColumnOrdinal, int destinationOrdinal){
55                 SourceOrdinal = sourceColumnOrdinal;
56                 DestinationOrdinal = destinationOrdinal;
57         }
58
59         public SqlBulkCopyColumnMapping(int sourceColumnOrdinal, string destinationColumn){
60                 SourceOrdinal = sourceColumnOrdinal;
61                 DestinationColumn = destinationColumn;  
62         }
63
64         public SqlBulkCopyColumnMapping(string sourceColumn, int destinationOrdinal){
65                 SourceColumn = sourceColumn;            
66                 DestinationOrdinal = destinationOrdinal;
67         }
68
69         public SqlBulkCopyColumnMapping(string sourceColumn, string destinationColumn){
70                 SourceColumn = sourceColumn;
71                 DestinationColumn = destinationColumn;
72         }
73
74         # endregion //Constructors      
75
76         # region Properties
77         
78         public String DestinationColumn {
79                 get {
80                         if (this.destinationColumn != null)
81                                 return destinationColumn;
82                         else
83                                 return string.Empty; //ms:doesnot return null.
84                 }
85                 set {
86                         // ms: whenever the name is set the ordinal is reset to -1
87                         this.destinationOrdinal = -1;
88                         this.destinationColumn = value;
89                 }
90         }
91         
92         public String SourceColumn {
93                 get {
94                         if (this.sourceColumn != null)
95                                 return sourceColumn;
96                         else
97                                 return string.Empty;//ms doesnot return null
98                 }
99                 set {
100                         // ms: whenever the name is set the ordinal is reset to -1
101                         this.sourceOrdinal = -1;
102                         this.sourceColumn = value;
103                 }
104         }
105
106         public int DestinationOrdinal {
107                 get {
108                          return this.destinationOrdinal;
109                 }
110                 set {
111                         // ms: whenever the ordinal is set, the name is null
112                         if (value < 0)
113                                 throw new IndexOutOfRangeException ();
114                         this.destinationColumn = null;
115                         this.destinationOrdinal =  value;
116                 }
117         }
118         
119         public int SourceOrdinal {
120                 get {
121                          return this.sourceOrdinal;
122                 }
123                 set {
124                         // ms: whenever the ordinal is set, the name is null
125                         if (value < 0)
126                                 throw new IndexOutOfRangeException ();
127                         this.sourceColumn = null;
128                         this.sourceOrdinal =  value;
129                 }
130         }
131
132         #endregion //Properties 
133
134         }
135 }
136