public class TableKeysInfo { private List keyList = new List(); /// /// The table to backup /// public string TableName { get; set; } public TableKeysInfo(string tableName, string[] keys) { if (tableName == null) { throw new ArgumentNullException("tableName"); } if (keys == null) { throw new ArgumentNullException("keys"); } this.TableName = tableName; // sort the keys Array.Sort(keys, StringComparer.InvariantCulture); // split key list {A, M, X} into {[null-A), [A-M), [M-X), [X-null)} this.keyList.Add(new PartitionKeyRange(null, keys.Length > 0 ? keys[0] : null)); for (int i = 1; i < keys.Length; i++) { this.keyList.Add(new PartitionKeyRange(keys[i - 1], keys[i])); } if (keys.Length > 0) { this.keyList.Add(new PartitionKeyRange(keys[keys.Length - 1], null)); } } /// /// The ranges of keys that will cover the entire table /// internal IEnumerable KeyRangeList { get { return this.keyList.AsEnumerable(); } } } |