DbDataReader.cs 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148
  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
  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. public abstract int VisibleFieldCount { get; }
  51. #endregion // Properties
  52. #region Methods
  53. public abstract void Close ();
  54. public abstract void Dispose ();
  55. public abstract bool GetBoolean (int i);
  56. public abstract byte GetByte (int i);
  57. public abstract long GetBytes (int i, long fieldOffset, byte[] buffer, int bufferOffset, int length);
  58. public abstract char GetChar (int i);
  59. public abstract long GetChars (int i, long dataIndex, char[] buffer, int bufferIndex, int length);
  60. [MonoTODO]
  61. public DbDataReader GetData (int i)
  62. {
  63. throw new NotImplementedException ();
  64. }
  65. public abstract string GetDataTypeName (int i);
  66. public abstract DateTime GetDateTime (int i);
  67. public abstract decimal GetDecimal (int i);
  68. public abstract double GetDouble (int i);
  69. public abstract IEnumerator GetEnumerator ();
  70. public abstract Type GetFieldProviderSpecificType (int i);
  71. public abstract Type GetFieldType (int i);
  72. public abstract float GetFloat (int i);
  73. public abstract Guid GetGuid (int i);
  74. public abstract short GetInt16 (int i);
  75. public abstract int GetInt32 (int i);
  76. public abstract long GetInt64 (int i);
  77. public abstract string GetName (int i);
  78. public abstract int GetOrdinal (string name);
  79. public abstract object GetProviderSpecificValue (int i);
  80. public abstract int GetProviderSpecificValues (object[] values);
  81. public abstract DataTable GetSchemaTable ();
  82. public abstract string GetString (int i);
  83. public abstract object GetValue (int i);
  84. public abstract int GetValues (object[] values);
  85. IDataReader IDataRecord.GetData (int i)
  86. {
  87. return ((IDataReader) this).GetData (i);
  88. }
  89. public abstract bool IsDBNull (int i);
  90. public abstract bool NextResult ();
  91. public abstract bool Read ();
  92. internal static DataTable GetSchemaTableTemplate ()
  93. {
  94. Type booleanType = Type.GetType ("System.Boolean");
  95. Type stringType = Type.GetType ("System.String");
  96. Type intType = Type.GetType ("System.Int32");
  97. Type typeType = Type.GetType ("System.Type");
  98. Type shortType = Type.GetType ("System.Int16");
  99. DataTable schemaTable = new DataTable ("SchemaTable");
  100. schemaTable.Columns.Add ("ColumnName", stringType);
  101. schemaTable.Columns.Add ("ColumnOrdinal", intType);
  102. schemaTable.Columns.Add ("ColumnSize", intType);
  103. schemaTable.Columns.Add ("NumericPrecision", shortType);
  104. schemaTable.Columns.Add ("NumericScale", shortType);
  105. schemaTable.Columns.Add ("IsUnique", booleanType);
  106. schemaTable.Columns.Add ("IsKey", booleanType);
  107. schemaTable.Columns.Add ("BaseServerName", stringType);
  108. schemaTable.Columns.Add ("BaseCatalogName", stringType);
  109. schemaTable.Columns.Add ("BaseColumnName", stringType);
  110. schemaTable.Columns.Add ("BaseSchemaName", stringType);
  111. schemaTable.Columns.Add ("BaseTableName", stringType);
  112. schemaTable.Columns.Add ("DataType", typeType);
  113. schemaTable.Columns.Add ("AllowDBNull", booleanType);
  114. schemaTable.Columns.Add ("ProviderType", intType);
  115. schemaTable.Columns.Add ("IsAliased", booleanType);
  116. schemaTable.Columns.Add ("IsExpression", booleanType);
  117. schemaTable.Columns.Add ("IsIdentity", booleanType);
  118. schemaTable.Columns.Add ("IsAutoIncrement", booleanType);
  119. schemaTable.Columns.Add ("IsRowVersion", booleanType);
  120. schemaTable.Columns.Add ("IsHidden", booleanType);
  121. schemaTable.Columns.Add ("IsLong", booleanType);
  122. schemaTable.Columns.Add ("IsReadOnly", booleanType);
  123. return schemaTable;
  124. }
  125. #endregion // Methods
  126. }
  127. }
  128. #endif // NET_2_0