public Query Where(string fieldName, string matchTypeStr, object value) { var matchType = MatchTypeHelper.Parse(matchTypeStr); if (matchType == MatchType.Unknown) { throw new Exception("Unknown match type: " + matchTypeStr.ToString()); } var con = new Condition { Field = tab.FieldByName(fieldName), Type = matchType, Value = value, }; if (con.Field == null) { throw new Exception("Field not found:" + fieldName); } conditions.Add(con); return(this); }
public void GenFieldIndex(string name, string matchTypeStr, int begin, int end) { if (FieldCount == 0) { return; } if (FieldByIndex(0).KeyCount == 0) { throw new Exception("Require table data to gen index"); } var field = FieldByName(name); if (fields == null) { throw new Exception("Field not found:" + name); } var matchType = MatchTypeHelper.Parse(matchTypeStr); if (matchType == MatchType.Unknown) { throw new Exception("Unknown match type: " + matchTypeStr.ToString()); } // 遍历实际访问的数值 for (int i = begin; i <= end; i++) { var indexList = new List <object>(); switch (matchType) { case MatchType.NotEqual: { for (int j = i; j <= end; j++) { if (j == i) { continue; } var list = field.GetByKey(j, field.FieldType); indexList.AddRange(list); } } break; case MatchType.Great: { // 大于当前值的所有列表合并 for (int j = i + 1; j <= end; j++) { var list = field.GetByKey(j, field.FieldType); indexList.AddRange(list); } } break; case MatchType.GreatEqual: { // 大于等于当前值的所有列表合并 for (int j = i; j <= end; j++) { var list = field.GetByKey(j, field.FieldType); indexList.AddRange(list); } } break; case MatchType.Less: { for (int j = begin; j < i; j++) { var list = field.GetByKey(j, field.FieldType); indexList.AddRange(list); } } break; case MatchType.LessEqual: { for (int j = begin; j <= i; j++) { var list = field.GetByKey(j, field.FieldType); indexList.AddRange(list); } } break; } field.AddIndexData(matchType, i, indexList); } }