private IEnumerable<ParadoxRecord> Enumerate(ParadoxCondition condition, ushort blockId, int indexLevel) { if (indexLevel == 0) { var block = this.table.GetBlock(blockId); for (int i=0; i<block.RecordCount; i++) { var rec = block[i]; if (condition.IsDataOk(rec)) { yield return rec; } } } else { var block = this.GetBlock(blockId); var blockIdFldIndex = this.FieldCount - 3; for (int i = 0; i < block.RecordCount; i++) { var rec = block[i]; if (condition.IsIndexPossible(rec, i < block.RecordCount-1 ? block[i + 1] : null)) { var qry = Enumerate(condition, (ushort)((short) rec.DataValues[blockIdFldIndex]-1), indexLevel - 1); foreach (var dataRec in qry) { yield return dataRec; } } } } }
private IEnumerable <ParadoxRecord> Enumerate(ParadoxCondition condition, ushort blockId, int indexLevel) { if (indexLevel == 0) { var block = this.table.GetBlock(blockId); for (int i = 0; i < block.RecordCount; i++) { var rec = block[i]; if (condition.IsDataOk(rec)) { yield return(rec); } } } else { var block = this.GetBlock(blockId); var blockIdFldIndex = this.FieldCount - 3; for (int i = 0; i < block.RecordCount; i++) { var rec = block[i]; if (condition.IsIndexPossible(rec, i < block.RecordCount - 1 ? block[i + 1] : null)) { var qry = Enumerate(condition, (ushort)((short)rec.DataValues[blockIdFldIndex] - 1), indexLevel - 1); foreach (var dataRec in qry) { yield return(dataRec); } } } } }
/// <summary> /// 获取数据库游标 /// </summary> /// <param name="tableName">要查询的数据库表名称</param> /// <param name="where">数据库查询条件</param> /// <param name="useIndex">是否使用数据库索引</param> /// <returns></returns> public ParadoxDataReader ExecuteQuery(string tableName, ParadoxCondition where, bool useIndex) { var table = GetParadoxTable(tableName); IEnumerable<ParadoxRecord> qry = null; if (useIndex) { var index = table.PrimaryKeyIndex; // index qry = index.Enumerate(where); // query } else { qry = table.Enumerate(where); // query } return new ParadoxDataReader(table, qry); // reader }
// modified by zsl: use Query Condition instead of 'Predicate<ParadoxRecord> where' //public IEnumerable<ParadoxRecord> Enumerate(Predicate<ParadoxRecord> where) public IEnumerable <ParadoxRecord> Enumerate(ParadoxCondition condition) { for (int blockId = 0; blockId < this.fileBlocks; blockId++) { var block = this.GetBlock(blockId); for (var recId = 0; recId < block.RecordCount; recId++) { var rec = block[recId]; //if (where == null || where(rec)) if (condition == null || condition.IsDataOk(rec)) { yield return(rec); } } } }
// modified by zsl: use Query Condition instead of 'Predicate<ParadoxRecord> where' //public IEnumerable<ParadoxRecord> Enumerate(Predicate<ParadoxRecord> where) public IEnumerable<ParadoxRecord> Enumerate(ParadoxCondition condition) { for (int blockId = 0; blockId < this.fileBlocks; blockId++) { var block = this.GetBlock(blockId); for (var recId = 0; recId < block.RecordCount; recId++) { var rec = block[recId]; //if (where == null || where(rec)) if (condition == null || condition.IsDataOk(rec)) { yield return rec; } } } }
public QueryArgs(string table, ParadoxCondition condition, string tag, string id) { this.TableName = table; this.Condition = condition; this.TagName = tag; this.IDName = id; }
public QueryArgs(string table, string tag, string id) { this.TableName = table; this.Condition = new NullCondtion(); this.TagName = tag; this.IDName = id; }
public QueryArgs(string table) { this.TableName = table; this.Condition = new NullCondtion(); this.TagName = ""; this.IDName = ""; }
public IEnumerable<ParadoxRecord> Enumerate(ParadoxCondition condition) { return Enumerate(condition, (ushort)(this.pxRootBlockId-1), this.pxLevelCount); }
protected Multiple(ParadoxCondition[] subConditions) { SubConditions = subConditions; }
public IEnumerable <ParadoxRecord> Enumerate(ParadoxCondition condition) { return(Enumerate(condition, (ushort)(this.pxRootBlockId - 1), this.pxLevelCount)); }
/// <summary> /// 获取数据库游标 /// </summary> /// <param name="tableName">要查询的数据库表名称</param> /// <param name="where">数据库查询条件</param> /// <returns></returns> public ParadoxDataReader ExecuteQuery(string tableName, ParadoxCondition where) { return ExecuteQuery(tableName, where, true); }