Esempio n. 1
0
        public void AddRow(object pk, object fk, object[] columns)
        {
            // remember: notsaved columns are passed here and will/should be truncated later
            if (columns.Length < Fields.Count)
            {
                throw new ArgumentException();
            }

            var row = _dataTable.NewRow();
            var idx = 0;

            if (AutomaticPrimaryKey)
            {
                row[idx++] = pk;
            }
            if (!IsTopTable)
            {
                row[idx++] = fk;
            }
            for (var col = 0; col < Fields.Count; col++)
            {
                row[idx++] = columns[col] ?? DBNull.Value;
            }
            _dataTable.Rows.Add(row);

            if (_dataTable.Rows.Count >= _flushThreshold)
            {
                TableManager.Save(this);
            }
        }