CSQLiteQuery.cs 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6. namespace OTSModelSharp.DTLBase
  7. {
  8. public class CSQLiteQuery : IDBQueryBase
  9. {
  10. private System.Data.SQLite.SQLiteDataReader reader;
  11. public CSQLiteQuery(System.Data.SQLite.SQLiteDataReader a_reader)
  12. {
  13. reader = a_reader;
  14. }
  15. public void Close()
  16. {
  17. reader.Close();
  18. }
  19. public byte[] GetColBlobValue(int a_nColIndex, int a_nLen)
  20. {
  21. byte[] val = new byte[a_nLen];
  22. reader.GetBytes(a_nColIndex, 0, val, 0, a_nLen);
  23. return val;
  24. }
  25. public int GetColCount()
  26. {
  27. return reader.FieldCount;
  28. }
  29. public double GetColFloatValue(int a_nColIndex, double a_dNullValue = 0)
  30. {
  31. return reader.GetDouble(a_nColIndex);
  32. }
  33. public int GetColIntValue(int a_nColIndex, int a_nNullValue)
  34. {
  35. return reader.GetInt32(a_nColIndex);
  36. }
  37. public string GetColName(int a_nColIndex)
  38. {
  39. return reader.GetName(a_nColIndex);
  40. }
  41. public string GetColStringValue(int a_nColIndex, string a_sNullValue = "")
  42. {
  43. return reader.GetString(a_nColIndex);
  44. }
  45. public Type GetColType(int a_nColIndex)
  46. {
  47. return reader.GetFieldType(a_nColIndex);
  48. }
  49. public string GetColValue(int a_nColIndex)
  50. {
  51. return (string)reader.GetValue(a_nColIndex);
  52. }
  53. public bool IsColNull(int a_nColIndex)
  54. {
  55. return reader.IsDBNull(a_nColIndex);
  56. }
  57. public bool IsEOF()
  58. {
  59. return !reader.HasRows;
  60. }
  61. public bool IsValid()
  62. {
  63. return !reader.IsClosed;
  64. }
  65. public bool NextRow()
  66. {
  67. reader.Read();
  68. return true;
  69. }
  70. }
  71. }