public bool Filter(Row r) { if ((string)r[Field] != Value) { return false; } return true; }
public ITable Execute(Database db) { ITable t = db.Tables[Query.TableName]; Row nr = new Row(t); foreach (Set s in Query.Sets) { nr[s.Field] = s.Value; } t.AddRow(nr); return null; }
// <summary>Retrieve the next row. Uses a seek, // assuming the underlying framework will be sensible about it // (we should usually already be in position)</summary> public Row NextRow() { _fs.Seek(this.Header.Size + (this._currentRow * this.Header.RowLength),0); Row r = new Row(this); r.BinRead(this.Columns, this._br); this._currentRow++; return r; }
// <summary> // Writes a row to disk // </summary> public void AddRow(Row r) { if (r.Table != this) { throw new InvalidOperationException("Can't add row - doesn't belong to this table"); } _fs.Seek(_fs.Length, 0); BinaryWriter bw = new BinaryWriter(_fs); r.BinWrite(bw); this.Header.RowCount += 1; _fs.Seek(0, 0); this.Header.BinWrite(bw); bw.Flush(); }
public override bool NextResult() { if (!this.UnderlyingTable.HasRows) { return false; } this.CurrentRow = this.UnderlyingTable.NextRow(); return true; }
// <summary>Generally used for creating new rows out of // old ones, particularly when joining rows together</summary> public void CopyData(Row old, List<Column> newColumns) { object[] oldd = this._data; this._data = new object[this.Table.Columns.Count]; oldd.CopyTo(this._data, 0); foreach (Column c in newColumns) { // Check if the column exists on this table, // if it does copy the value in if (this.Table.Columns.Find(o => o.Name == c.Name) != null && old.Table.Columns.Find(o => o.Name == c.Name) != null) { // find the matching old column this[c.Name] = old[c.Name]; } } }