InternalDataReader.cs 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154
  1. using Ant.Common;
  2. using Ant.Utility;
  3. using System;
  4. using System.Data;
  5. namespace Ant.Core
  6. {
  7. class InternalDataReader : IDataReader, IDisposable, IDataRecord
  8. {
  9. private SqlDataAccess _dbSession;
  10. private IDataReader _reader;
  11. public InternalDataReader(SqlDataAccess dbSession, IDataReader reader)
  12. {
  13. AntUtils.CheckNull(dbSession);
  14. AntUtils.CheckNull(reader);
  15. this._dbSession = dbSession;
  16. this._reader = reader;
  17. }
  18. #region IDataReader
  19. public int Depth { get { return this._reader.Depth; } }
  20. public bool IsClosed { get { return this._reader.IsClosed; } }
  21. public int RecordsAffected { get { return this._reader.RecordsAffected; } }
  22. public void Close()
  23. {
  24. if (this._reader != null && !this._reader.IsClosed)
  25. this._reader.Close();
  26. this._dbSession.Close();
  27. }
  28. public DataTable GetSchemaTable()
  29. {
  30. return this._reader.GetSchemaTable();
  31. }
  32. public bool NextResult()
  33. {
  34. return this._reader.NextResult();
  35. }
  36. public bool Read()
  37. {
  38. return this._reader.Read();
  39. }
  40. public void Dispose()
  41. {
  42. if (this._reader != null)
  43. {
  44. if (!this._reader.IsClosed)
  45. this._reader.Close();
  46. this._reader.Dispose();
  47. }
  48. this._dbSession.Close();
  49. }
  50. #endregion
  51. #region IDataRecord
  52. public int FieldCount { get { return this._reader.FieldCount; } }
  53. public object this[int i] { get { return this._reader[i]; } }
  54. public object this[string name] { get { return this._reader[name]; } }
  55. public bool GetBoolean(int i)
  56. {
  57. return this._reader.GetBoolean(i);
  58. }
  59. public byte GetByte(int i)
  60. {
  61. return this._reader.GetByte(i);
  62. }
  63. public long GetBytes(int i, long fieldOffset, byte[] buffer, int bufferoffset, int length)
  64. {
  65. return this._reader.GetBytes(i, fieldOffset, buffer, bufferoffset, length);
  66. }
  67. public char GetChar(int i)
  68. {
  69. return this._reader.GetChar(i);
  70. }
  71. public long GetChars(int i, long fieldoffset, char[] buffer, int bufferoffset, int length)
  72. {
  73. return this._reader.GetChars(i, fieldoffset, buffer, bufferoffset, length);
  74. }
  75. public IDataReader GetData(int i)
  76. {
  77. return this._reader.GetData(i);
  78. }
  79. public string GetDataTypeName(int i)
  80. {
  81. return this._reader.GetDataTypeName(i);
  82. }
  83. public DateTime GetDateTime(int i)
  84. {
  85. return this._reader.GetDateTime(i);
  86. }
  87. public decimal GetDecimal(int i)
  88. {
  89. return this._reader.GetDecimal(i);
  90. }
  91. public double GetDouble(int i)
  92. {
  93. return this._reader.GetDouble(i);
  94. }
  95. public Type GetFieldType(int i)
  96. {
  97. return this._reader.GetFieldType(i);
  98. }
  99. public float GetFloat(int i)
  100. {
  101. return this._reader.GetFloat(i);
  102. }
  103. public Guid GetGuid(int i)
  104. {
  105. return this._reader.GetGuid(i);
  106. }
  107. public short GetInt16(int i)
  108. {
  109. return this._reader.GetInt16(i);
  110. }
  111. public int GetInt32(int i)
  112. {
  113. return this._reader.GetInt32(i);
  114. }
  115. public long GetInt64(int i)
  116. {
  117. return this._reader.GetInt64(i);
  118. }
  119. public string GetName(int i)
  120. {
  121. return this._reader.GetName(i);
  122. }
  123. public int GetOrdinal(string name)
  124. {
  125. return this._reader.GetOrdinal(name);
  126. }
  127. public string GetString(int i)
  128. {
  129. return this._reader.GetString(i);
  130. }
  131. public object GetValue(int i)
  132. {
  133. return this._reader.GetValue(i);
  134. }
  135. public int GetValues(object[] values)
  136. {
  137. return this._reader.GetValues(values);
  138. }
  139. public bool IsDBNull(int i)
  140. {
  141. return this._reader.IsDBNull(i);
  142. }
  143. #endregion
  144. }
  145. }