Beispiel #1
0
 internal CdlRow(CdlTable table, ICdlRecord original, CdlRowState initialState, TableInfo structure)
 {
     m_table     = table;
     m_fields    = new FieldRec[m_table.Structure.Columns.Count];
     m_original  = original;
     m_structure = structure;
     RowState    = initialState;
 }
Beispiel #2
0
        //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);
        }
Beispiel #3
0
        public InMemoryTable(InMemoryTable oldTable, SingleTableDataScript script)
        {
            Initialize();
            m_structure = oldTable.Structure.CloneTable();
            CdlTable bt = new CdlTable(oldTable);

            bt.RunScript(script);
            foreach (ICdlRecord rec in bt.Rows)
            {
                m_rows.Add(new ArrayDataRecord(rec));
            }
        }
        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);
        }
Beispiel #5
0
        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);
        }
Beispiel #6
0
        public CdlTable LoadTableData(int start = 0, int?count = null)
        {
            lock (_directory)
            {
                CdlTable table = new CdlTable(_table);

                if (count == null)
                {
                    count = _serializedRows;
                }

                if (start >= _serializedRows)
                {
                    return(table);
                }
                int curdic = start / BUFFER_SIZE, skiprec = start % BUFFER_SIZE;
                _cache.Seek(_directory[curdic], SeekOrigin.Begin);

                int          availtables = _directory.Count - curdic;
                BinaryReader br          = new BinaryReader(_cache);
                while (table.Rows.Count < count && availtables >= 1)
                {
                    ChunkInfo info = ChunkInfo.LoadInfo(br);
                    if (skiprec > 0)
                    {
                        int skipbytes = 0;
                        for (int i = 0; i < skiprec; i++)
                        {
                            skipbytes += info.Lengths[i];
                        }
                        _cache.Seek(skipbytes, SeekOrigin.Current);
                    }
                    int rec = skiprec;

                    while (rec < info.Count)
                    {
                        table.AddRowInternal(CdlTool.LoadRecord(br, _table));
                        rec++;
                    }
                    availtables--;
                    skiprec = 0;
                }
                return(table);
            }
        }
 internal CdlRowCollection(CdlTable table)
 {
     m_table = table;
 }