List <List <string> > GetKeysInternal(ISqlTableSource tableSource) { //TODO: needed mechanism to define unique indexes. Currently only primary key is used // only from tables we can get keys if (!(tableSource is SqlTable)) { return(null); } var keys = tableSource.GetKeys(false); if (keys == null || keys.Count == 0) { return(null); } var fields = keys.Select(GetUnderlayingField) .Where(f => f != null) .Select(f => f.Name).ToList(); if (fields.Count != keys.Count) { return(null); } var knownKeys = new List <List <string> >(); knownKeys.Add(fields); return(knownKeys); }
private void AddConditions(SqlWhereClause where, ISqlTableSource table) { var keys = table.GetKeys(true); if (keys == null) { return; } foreach (var key in keys.OfType <SqlField>()) { var maxValue = GetMaxValue(key.DataType); if (maxValue == null) { continue; } var cond = new SqlSearchCondition(); cond = cond.Expr(key).IsNull.Or; if (maxValue is string) { cond.Expr(key).GreaterOrEqual.Expr(new SqlValue(maxValue)); } else { cond.Expr(key).LessOrEqual.Expr(new SqlValue(maxValue)); } where.ConcatSearchCondition(cond); // only one field is enough break; } }