/// <summary>
        /// Get the names of the columns as defined in the database
        /// </summary>
        /// <returns></returns>
        public string[] GetDbFieldNames()
        {
            string sql         = "select Top 1 * from " + TableName;
            var    reader      = MyDataSource.ExecuteReader(sql);
            var    schemaTable = reader.GetSchemaTable();

            MyDataSource.DisposeReader(reader);
            return((from dr in schemaTable?.Rows.Cast <DataRow>()
                    select dr["ColumnName"].ToString()).ToArray());
        }
        public int[] GetIDs(bool sortByID = false)
        {
            if (string.IsNullOrEmpty(IDField))
            {
                return(null);
            }

            var sql    = "select " + IDField + " from " + TableName + (sortByID ? " order by " + IDField + " asc;" : "");
            var r      = MyDataSource.ExecuteReader(sql);
            var result = new List <int>();

            while (r.Read())
            {
                var id = r.GetInt32(0);
                result.Add(id);
            }

            MyDataSource.DisposeReader(r);
            return(result.ToArray());
        }
        public TField[] GetFieldDistinctValues <TField>(string fieldName, bool sort = false)
        {
            var fi = typeof(T).GetField(fieldName);

            if (fi == null)
            {
                throw new Exception("FieldName doesn't match any public field in type");
            }
            int fiIndex = _fieldInfos.IndexOf(fi);
            var dbFn    = _dbFieldNames[fiIndex];
            var sql     = $"select distinct {dbFn} from {TableName}" + (sort ? $" order by {dbFn} asc;" : "");
            var r       = MyDataSource.ExecuteReader(sql);
            var result  = new List <TField>();

            while (r.Read())
            {
                var vO = r[0];
                result.Add((TField)vO);
            }
            MyDataSource.DisposeReader(r);
            return(result.ToArray());
        }