2 // System.Data.Common.DbDataReader.cs
5 // Tim Coleman (tim@timcoleman.com)
7 // Copyright (C) Tim Coleman, 2003
11 // Copyright (C) 2004 Novell, Inc (http://www.novell.com)
13 // Permission is hereby granted, free of charge, to any person obtaining
14 // a copy of this software and associated documentation files (the
15 // "Software"), to deal in the Software without restriction, including
16 // without limitation the rights to use, copy, modify, merge, publish,
17 // distribute, sublicense, and/or sell copies of the Software, and to
18 // permit persons to whom the Software is furnished to do so, subject to
19 // the following conditions:
21 // The above copyright notice and this permission notice shall be
22 // included in all copies or substantial portions of the Software.
24 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
25 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
26 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
27 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
28 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
29 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
30 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
33 #if NET_2_0 || TARGET_JVM
35 using System.Collections;
36 using System.ComponentModel;
39 namespace System.Data.Common {
40 public abstract class DbDataReader : MarshalByRefObject, IDataReader, IDataRecord, IDisposable, IEnumerable
44 protected DbDataReader ()
48 #endregion // Constructors
52 public abstract int Depth { get; }
53 public abstract int FieldCount { get; }
54 public abstract bool HasRows { get; }
55 public abstract bool IsClosed { get; }
56 public abstract object this [int index] { get; }
57 public abstract object this [string name] { get; }
58 public abstract int RecordsAffected { get; }
61 public virtual int VisibleFieldCount {
62 get { return FieldCount; }
65 #endregion // Properties
69 public abstract void Close ();
70 public abstract bool GetBoolean (int i);
71 public abstract byte GetByte (int i);
72 public abstract long GetBytes (int i, long fieldOffset, byte[] buffer, int bufferOffset, int length);
73 public abstract char GetChar (int i);
74 public abstract long GetChars (int i, long dataIndex, char[] buffer, int bufferIndex, int length);
76 [EditorBrowsable (EditorBrowsableState.Never)]
77 public void Dispose ()
82 protected virtual void Dispose (bool disposing)
88 [EditorBrowsable (EditorBrowsableState.Never)]
89 public DbDataReader GetData (int i)
91 return ((DbDataReader) this [i]);
95 public abstract string GetDataTypeName (int i);
96 public abstract DateTime GetDateTime (int i);
97 public abstract decimal GetDecimal (int i);
98 public abstract double GetDouble (int i);
100 [EditorBrowsable (EditorBrowsableState.Never)]
101 public abstract IEnumerator GetEnumerator ();
103 public abstract Type GetFieldType (int i);
104 public abstract float GetFloat (int i);
105 public abstract Guid GetGuid (int i);
106 public abstract short GetInt16 (int i);
107 public abstract int GetInt32 (int i);
108 public abstract long GetInt64 (int i);
109 public abstract string GetName (int i);
110 public abstract int GetOrdinal (string name);
113 [EditorBrowsable (EditorBrowsableState.Never)]
114 public virtual Type GetProviderSpecificFieldType (int i)
116 return GetFieldType (i);
119 [EditorBrowsable (EditorBrowsableState.Never)]
120 public virtual object GetProviderSpecificValue (int i)
125 [EditorBrowsable (EditorBrowsableState.Never)]
126 public virtual int GetProviderSpecificValues (object[] values)
128 return GetValues (values);
131 protected virtual DbDataReader GetDbDataReader (int ordinal)
133 return ((DbDataReader) this [ordinal]);
137 public abstract DataTable GetSchemaTable ();
138 public abstract string GetString (int i);
139 public abstract object GetValue (int i);
140 public abstract int GetValues (object[] values);
142 IDataReader IDataRecord.GetData (int i)
144 return ((IDataReader) this).GetData (i);
147 public abstract bool IsDBNull (int i);
148 public abstract bool NextResult ();
149 public abstract bool Read ();
151 internal static DataTable GetSchemaTableTemplate ()
153 Type booleanType = typeof (bool);
154 Type stringType = typeof (string);
155 Type intType = typeof (int);
156 Type typeType = typeof (Type);
157 Type shortType = typeof (short);
159 DataTable schemaTable = new DataTable ("SchemaTable");
160 schemaTable.Columns.Add ("ColumnName", stringType);
161 schemaTable.Columns.Add ("ColumnOrdinal", intType);
162 schemaTable.Columns.Add ("ColumnSize", intType);
163 schemaTable.Columns.Add ("NumericPrecision", shortType);
164 schemaTable.Columns.Add ("NumericScale", shortType);
165 schemaTable.Columns.Add ("IsUnique", booleanType);
166 schemaTable.Columns.Add ("IsKey", booleanType);
167 schemaTable.Columns.Add ("BaseServerName", stringType);
168 schemaTable.Columns.Add ("BaseCatalogName", stringType);
169 schemaTable.Columns.Add ("BaseColumnName", stringType);
170 schemaTable.Columns.Add ("BaseSchemaName", stringType);
171 schemaTable.Columns.Add ("BaseTableName", stringType);
172 schemaTable.Columns.Add ("DataType", typeType);
173 schemaTable.Columns.Add ("AllowDBNull", booleanType);
174 schemaTable.Columns.Add ("ProviderType", intType);
175 schemaTable.Columns.Add ("IsAliased", booleanType);
176 schemaTable.Columns.Add ("IsExpression", booleanType);
177 schemaTable.Columns.Add ("IsIdentity", booleanType);
178 schemaTable.Columns.Add ("IsAutoIncrement", booleanType);
179 schemaTable.Columns.Add ("IsRowVersion", booleanType);
180 schemaTable.Columns.Add ("IsHidden", booleanType);
181 schemaTable.Columns.Add ("IsLong", booleanType);
182 schemaTable.Columns.Add ("IsReadOnly", booleanType);
187 #endregion // Methods