using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace OTSModelSharp.DTLBase { public class CSQLiteQuery : IDBQueryBase { private System.Data.SQLite.SQLiteDataReader reader; public CSQLiteQuery(System.Data.SQLite.SQLiteDataReader a_reader) { reader = a_reader; } public void Close() { reader.Close(); } public byte[] GetColBlobValue(int a_nColIndex, int a_nLen) { byte[] val = new byte[a_nLen]; reader.GetBytes(a_nColIndex, 0, val, 0, a_nLen); return val; } public int GetColCount() { return reader.FieldCount; } public double GetColFloatValue(int a_nColIndex, double a_dNullValue = 0) { return reader.GetDouble(a_nColIndex); } public int GetColIntValue(int a_nColIndex, int a_nNullValue) { return reader.GetInt32(a_nColIndex); } public string GetColName(int a_nColIndex) { return reader.GetName(a_nColIndex); } public string GetColStringValue(int a_nColIndex, string a_sNullValue = "") { return reader.GetString(a_nColIndex); } public Type GetColType(int a_nColIndex) { return reader.GetFieldType(a_nColIndex); } public string GetColValue(int a_nColIndex) { string readerValue = ""; while (reader.Read()) { readerValue = (string)reader.GetValue(a_nColIndex); } return readerValue; } public bool IsColNull(int a_nColIndex) { return reader.IsDBNull(a_nColIndex); } public bool IsEOF() { return !reader.HasRows; } public bool IsValid() { return !reader.IsClosed; } public bool NextRow() { reader.Read(); return true; } } }