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; }
62 public virtual int VisibleFieldCount {
63 get { return FieldCount; }
66 #endregion // Properties
70 public abstract void Close ();
71 public abstract bool GetBoolean (int i);
72 public abstract byte GetByte (int i);
73 public abstract long GetBytes (int i, long fieldOffset, byte[] buffer, int bufferOffset, int length);
74 public abstract char GetChar (int i);
75 public abstract long GetChars (int i, long dataIndex, char[] buffer, int bufferIndex, int length);
77 [EditorBrowsable (EditorBrowsableState.Never)]
78 public void Dispose ()
83 protected virtual void Dispose (bool disposing)
90 [EditorBrowsable (EditorBrowsableState.Never)]
91 public DbDataReader GetData (int i)
93 throw new NotImplementedException ();
97 public abstract string GetDataTypeName (int i);
98 public abstract DateTime GetDateTime (int i);
99 public abstract decimal GetDecimal (int i);
100 public abstract double GetDouble (int i);
102 [EditorBrowsable (EditorBrowsableState.Never)]
103 public abstract IEnumerator GetEnumerator ();
105 public abstract Type GetFieldType (int i);
106 public abstract float GetFloat (int i);
107 public abstract Guid GetGuid (int i);
108 public abstract short GetInt16 (int i);
109 public abstract int GetInt32 (int i);
110 public abstract long GetInt64 (int i);
111 public abstract string GetName (int i);
112 public abstract int GetOrdinal (string name);
116 [EditorBrowsable (EditorBrowsableState.Never)]
117 public virtual Type GetProviderSpecificFieldType (int i)
119 return GetFieldType (i);
123 [EditorBrowsable (EditorBrowsableState.Never)]
124 public virtual object GetProviderSpecificValue (int i)
130 [EditorBrowsable (EditorBrowsableState.Never)]
131 public virtual int GetProviderSpecificValues (object[] values)
133 return GetValues (values);
137 protected virtual DbDataReader GetDbDataReader (int ordinal)
139 throw new NotSupportedException ();
143 public abstract DataTable GetSchemaTable ();
144 public abstract string GetString (int i);
145 public abstract object GetValue (int i);
146 public abstract int GetValues (object[] values);
148 IDataReader IDataRecord.GetData (int i)
150 return ((IDataReader) this).GetData (i);
153 public abstract bool IsDBNull (int i);
154 public abstract bool NextResult ();
155 public abstract bool Read ();
157 internal static DataTable GetSchemaTableTemplate ()
159 Type booleanType = Type.GetType ("System.Boolean");
160 Type stringType = Type.GetType ("System.String");
161 Type intType = Type.GetType ("System.Int32");
162 Type typeType = Type.GetType ("System.Type");
163 Type shortType = Type.GetType ("System.Int16");
165 DataTable schemaTable = new DataTable ("SchemaTable");
166 schemaTable.Columns.Add ("ColumnName", stringType);
167 schemaTable.Columns.Add ("ColumnOrdinal", intType);
168 schemaTable.Columns.Add ("ColumnSize", intType);
169 schemaTable.Columns.Add ("NumericPrecision", shortType);
170 schemaTable.Columns.Add ("NumericScale", shortType);
171 schemaTable.Columns.Add ("IsUnique", booleanType);
172 schemaTable.Columns.Add ("IsKey", booleanType);
173 schemaTable.Columns.Add ("BaseServerName", stringType);
174 schemaTable.Columns.Add ("BaseCatalogName", stringType);
175 schemaTable.Columns.Add ("BaseColumnName", stringType);
176 schemaTable.Columns.Add ("BaseSchemaName", stringType);
177 schemaTable.Columns.Add ("BaseTableName", stringType);
178 schemaTable.Columns.Add ("DataType", typeType);
179 schemaTable.Columns.Add ("AllowDBNull", booleanType);
180 schemaTable.Columns.Add ("ProviderType", intType);
181 schemaTable.Columns.Add ("IsAliased", booleanType);
182 schemaTable.Columns.Add ("IsExpression", booleanType);
183 schemaTable.Columns.Add ("IsIdentity", booleanType);
184 schemaTable.Columns.Add ("IsAutoIncrement", booleanType);
185 schemaTable.Columns.Add ("IsRowVersion", booleanType);
186 schemaTable.Columns.Add ("IsHidden", booleanType);
187 schemaTable.Columns.Add ("IsLong", booleanType);
188 schemaTable.Columns.Add ("IsReadOnly", booleanType);
193 #endregion // Methods