DbDataReader.cs 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158
  1. //
  2. // System.Data.Common.DbDataReader.cs
  3. //
  4. // Author:
  5. // Tim Coleman ([email protected])
  6. //
  7. // Copyright (C) Tim Coleman, 2003
  8. //
  9. //
  10. // Copyright (C) 2004 Novell, Inc (http://www.novell.com)
  11. //
  12. // Permission is hereby granted, free of charge, to any person obtaining
  13. // a copy of this software and associated documentation files (the
  14. // "Software"), to deal in the Software without restriction, including
  15. // without limitation the rights to use, copy, modify, merge, publish,
  16. // distribute, sublicense, and/or sell copies of the Software, and to
  17. // permit persons to whom the Software is furnished to do so, subject to
  18. // the following conditions:
  19. //
  20. // The above copyright notice and this permission notice shall be
  21. // included in all copies or substantial portions of the Software.
  22. //
  23. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  24. // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  25. // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  26. // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
  27. // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
  28. // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
  29. // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  30. //
  31. #if NET_2_0 || TARGET_JVM
  32. using System.Collections;
  33. using System.Data;
  34. namespace System.Data.Common {
  35. public abstract class DbDataReader : MarshalByRefObject, IDataReader, IDataReader2, IDataRecord, IDataRecord2, IDisposable, IEnumerable
  36. {
  37. #region Constructors
  38. protected DbDataReader ()
  39. {
  40. }
  41. #endregion // Constructors
  42. #region Properties
  43. public abstract int Depth { get; }
  44. public abstract int FieldCount { get; }
  45. public abstract bool HasRows { get; }
  46. public abstract bool IsClosed { get; }
  47. public abstract object this [int index] { get; }
  48. public abstract object this [string name] { get; }
  49. public abstract int RecordsAffected { get; }
  50. #if NET_2_0
  51. public abstract int VisibleFieldCount { get; }
  52. #endif
  53. #endregion // Properties
  54. #region Methods
  55. public abstract void Close ();
  56. public abstract void Dispose ();
  57. public abstract bool GetBoolean (int i);
  58. public abstract byte GetByte (int i);
  59. public abstract long GetBytes (int i, long fieldOffset, byte[] buffer, int bufferOffset, int length);
  60. public abstract char GetChar (int i);
  61. public abstract long GetChars (int i, long dataIndex, char[] buffer, int bufferIndex, int length);
  62. #if NET_2_0
  63. [MonoTODO]
  64. public DbDataReader GetData (int i)
  65. {
  66. throw new NotImplementedException ();
  67. }
  68. #endif
  69. public abstract string GetDataTypeName (int i);
  70. public abstract DateTime GetDateTime (int i);
  71. public abstract decimal GetDecimal (int i);
  72. public abstract double GetDouble (int i);
  73. public abstract IEnumerator GetEnumerator ();
  74. #if NET_2_0
  75. public abstract Type GetFieldProviderSpecificType (int i);
  76. #endif
  77. public abstract Type GetFieldType (int i);
  78. public abstract float GetFloat (int i);
  79. public abstract Guid GetGuid (int i);
  80. public abstract short GetInt16 (int i);
  81. public abstract int GetInt32 (int i);
  82. public abstract long GetInt64 (int i);
  83. public abstract string GetName (int i);
  84. public abstract int GetOrdinal (string name);
  85. #if NET_2_0
  86. public abstract object GetProviderSpecificValue (int i);
  87. public abstract int GetProviderSpecificValues (object[] values);
  88. #endif
  89. public abstract DataTable GetSchemaTable ();
  90. public abstract string GetString (int i);
  91. public abstract object GetValue (int i);
  92. public abstract int GetValues (object[] values);
  93. IDataReader IDataRecord.GetData (int i)
  94. {
  95. return ((IDataReader) this).GetData (i);
  96. }
  97. public abstract bool IsDBNull (int i);
  98. public abstract bool NextResult ();
  99. public abstract bool Read ();
  100. internal static DataTable GetSchemaTableTemplate ()
  101. {
  102. Type booleanType = Type.GetType ("System.Boolean");
  103. Type stringType = Type.GetType ("System.String");
  104. Type intType = Type.GetType ("System.Int32");
  105. Type typeType = Type.GetType ("System.Type");
  106. Type shortType = Type.GetType ("System.Int16");
  107. DataTable schemaTable = new DataTable ("SchemaTable");
  108. schemaTable.Columns.Add ("ColumnName", stringType);
  109. schemaTable.Columns.Add ("ColumnOrdinal", intType);
  110. schemaTable.Columns.Add ("ColumnSize", intType);
  111. schemaTable.Columns.Add ("NumericPrecision", shortType);
  112. schemaTable.Columns.Add ("NumericScale", shortType);
  113. schemaTable.Columns.Add ("IsUnique", booleanType);
  114. schemaTable.Columns.Add ("IsKey", booleanType);
  115. schemaTable.Columns.Add ("BaseServerName", stringType);
  116. schemaTable.Columns.Add ("BaseCatalogName", stringType);
  117. schemaTable.Columns.Add ("BaseColumnName", stringType);
  118. schemaTable.Columns.Add ("BaseSchemaName", stringType);
  119. schemaTable.Columns.Add ("BaseTableName", stringType);
  120. schemaTable.Columns.Add ("DataType", typeType);
  121. schemaTable.Columns.Add ("AllowDBNull", booleanType);
  122. schemaTable.Columns.Add ("ProviderType", intType);
  123. schemaTable.Columns.Add ("IsAliased", booleanType);
  124. schemaTable.Columns.Add ("IsExpression", booleanType);
  125. schemaTable.Columns.Add ("IsIdentity", booleanType);
  126. schemaTable.Columns.Add ("IsAutoIncrement", booleanType);
  127. schemaTable.Columns.Add ("IsRowVersion", booleanType);
  128. schemaTable.Columns.Add ("IsHidden", booleanType);
  129. schemaTable.Columns.Add ("IsLong", booleanType);
  130. schemaTable.Columns.Add ("IsReadOnly", booleanType);
  131. return schemaTable;
  132. }
  133. #endregion // Methods
  134. }
  135. }
  136. #endif