2010-06-03 Jb Evain <jbevain@novell.com>
[mcs.git] / class / System.Data / System.Data.SqlClient / SqlBulkCopyColumnMapping.cs
bloba572484caea53eb0215d33be7c6b155440c9bd6f
1 //
2 // System.Data.SqlClient.SqlBulkCopyColumnMapping.cs
3 //
4 // Author:
5 // Umadevi S <sumadevi@novell.com>
6 //
8 //
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:
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.
31 #if NET_2_0
32 namespace System.Data.SqlClient
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>
39 public sealed class SqlBulkCopyColumnMapping {
41 #region Fields
43 int sourceOrdinal = -1;
44 int destinationOrdinal = -1;
45 string sourceColumn = null;
46 string destinationColumn = null;
48 #endregion //Fields
50 #region Constructors
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
77 # region Properties
79 public String DestinationColumn {
80 get {
81 if (this.destinationColumn != null)
82 return destinationColumn;
83 else
84 return string.Empty; //ms:doesnot return null.
86 set {
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 {
94 get {
95 if (this.sourceColumn != null)
96 return sourceColumn;
97 else
98 return string.Empty;//ms doesnot return null
100 set {
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 {
108 get {
109 return this.destinationOrdinal;
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;
120 public int SourceOrdinal {
121 get {
122 return this.sourceOrdinal;
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;
133 #endregion //Properties
138 #endif