コード例 #1
0
ファイル: CdlTable.cs プロジェクト: timothydodd/dbshell
        //public TColumnDisplay<ColumnInfo> GetColumnDisplay()
        //{
        //    var res = new TColumnDisplay<ColumnInfo>();
        //    var pk = Structure.PrimaryKey;
        //    var pkcols = new List<string>();
        //    if (pk != null) pkcols = new List<string>(pk.Columns.GetNames());
        //    if (ResultFields == null)
        //    {
        //        for (int i = 0; i < Structure.Columns.Count; i++)
        //        {
        //            var col = Structure.Columns[i];
        //            var di = new ColumnDisplayInfo { IsPrimaryKey = pkcols.Contains(col.Name) };
        //            res.AddColumn(col.Name, i, col);
        //        }
        //    }
        //    else
        //    {
        //        for (int i = 0; i < Math.Min(Structure.Columns.Count, ResultFields.Count); i++)
        //        {
        //            var col = Structure.Columns[i];
        //            res.AddColumn(ResultFields[i], i, col);
        //        }
        //    }
        //    return res;
        //}

        public CdlTable GetFirstRows(int count)
        {
            var res = new CdlTable(Structure);

            for (int i = 0; i < Math.Min(count, Rows.Count); i++)
            {
                res.AddRow(Rows[i]);
            }
            return(res);
        }
コード例 #2
0
        public static CdlTable ToBinaryTable(this ICdlReader reader, int?maximumRecords)
        {
            //TableInfo ts = reader.GetTableInfo();
            CdlTable dt         = new CdlTable(reader.Structure);
            int      allow_recs = maximumRecords != null ? maximumRecords.Value : -1;

            while (reader.Read() && (maximumRecords == null || allow_recs > 0))
            {
                dt.AddRow(reader);
                allow_recs--;
            }
            return(dt);
        }
コード例 #3
0
ファイル: CdlTable.cs プロジェクト: timothydodd/dbshell
        public CdlTable Filter(Func <CdlRow, bool> filter)
        {
            CdlTable res = new CdlTable(m_structure);

            res.m_convertor = m_convertor;
            foreach (var row in Rows)
            {
                if (filter(row))
                {
                    res.AddRow(row);
                }
            }
            return(res);
        }