2004-03-10 Umadevi S (sumadevi@novell.com)
[mono.git] / mcs / class / System.Data / System.Data.Sql / SqlDefinition.cs
1 //
2 // System.Data.Sql.SqlDefinition
3 //
4 // Author:
5 //   Tim Coleman (tim@timcoleman.com)
6 //
7 // Copyright (C) Tim Coleman, 2003
8 //
9
10 #if NET_1_2
11
12 using System;
13
14 namespace System.Data.Sql {
15         public sealed class SqlDefinition
16         {
17                 #region Fields
18
19                 ISqlCommand cmd;
20                 string cmdText;
21                 CommandType cmdType;
22                 SqlMetaData[] metadata;
23                 ParameterDirection[] parmDirection;
24
25                 #endregion // Fields
26
27                 #region Constructors
28
29                 public SqlDefinition (ISqlCommand cmd)
30                 {
31                         this.cmd = cmd;
32                         this.cmdText = cmd.CommandText;
33                         this.cmdType = cmd.CommandType;
34                 }
35
36                 public SqlDefinition (string cmdText, CommandType cmdType, SqlMetaData[] metadata, ParameterDirection[] parmDirection)
37                 {
38                         this.cmd = null;
39                         this.cmdText = cmdText;
40                         this.cmdType = cmdType;
41                         this.metadata = metadata;
42                         this.parmDirection = parmDirection;
43                 }
44
45                 #endregion // Constructors
46
47                 #region Properties
48                         
49                 public string CommandText {
50                         get { 
51                                 if (cmd == null)
52                                         return cmdText;
53                                 return cmd.CommandText;
54                         }
55                 }
56
57                 public CommandType CommandType {
58                         get { 
59                                 if (cmd == null)
60                                         return cmdType;
61                                 return cmd.CommandType;
62                         }
63                 }
64
65                 [MonoTODO]
66                 public int ParameterCount {
67                         get { 
68                                 if (cmd == null)
69                                         throw new NotImplementedException ();
70                                 return cmd.Parameters.Count;
71                         }
72                 }
73
74                 #endregion // Properties
75
76                 #region Methods
77
78                 public ParameterDirection GetParameterDirection (int i)
79                 {
80                         if (cmd == null)
81                                 return parmDirection [i];
82
83                         return cmd.Parameters [i].Direction;
84
85                 }
86
87                 public SqlMetaData GetSqlMetaData (int i)
88                 {
89                         if (cmd == null)
90                                 return metadata [i];
91
92                         return cmd.Parameters [i].MetaData;
93                 }
94
95                 #endregion // Methods
96         }
97 }
98
99 #endif