Skip to content

Commit 80bb6cc

Browse files
authored
Merge pull request #9 from giometrix/secondary_index
Secondary index
2 parents c7ec853 + 3843310 commit 80bb6cc

23 files changed

+1879
-647
lines changed

README.md

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,40 @@ Note that our table store was ```PocoTableStore<Employee, int, int>```, but that
188188
```var record = tableStore.GetRecord(142, "user");```
189189
which is both clear and provides type safety.
190190

191+
#### Sequential Keys
192+
`SequentialKeyMapper` was introduced in v2.6 and is a bit different from other key mappers because the output isn't meant for point lookups. This key mapper assigns keys in sequential order (forward or backward). Because Azure Table Storage orders rows by row key, a sequential key allows you to use Azure Table Storage as a log.
193+
194+
Coupled with TODO , you can do things like saving a historical record when mutating your main table entity.
195+
196+
Example:
197+
```csharp
198+
var pKeyMapper = new KeyMapper<Employee, int>(e => e.Id.ToString(), int.Parse, e => e.Id, id => id.ToString());
199+
200+
var rKeyMapper = new SequentialKeyMapper<Employee, int>(true);
201+
202+
var keysConverter = new CalculatedKeysConverter<Employee, int, int>(pKeyMapper, rKeyMapper);
203+
204+
tableStore = new PocoTableStore<Employee, int, int>("TestEmployee", "UseDevelopmentStorage=true", keysConverter);
205+
206+
var employee = new Employee
207+
{
208+
CompanyId = 1,
209+
Id = 242443,
210+
Name = "1",
211+
Department = new Department { Id = 22, Name = "Executive" }
212+
};
213+
214+
tableStore.Insert(employee);
215+
216+
employee.Name = "2";
217+
tableStore.Insert(employee);
218+
219+
employee.Name = "3";
220+
tableStore.Insert(employee);
221+
222+
// order will be 3, 2, 1 because we are sorting in sequential order
223+
```
224+
191225
### Further Filtering (Beyond Partition & Row Keys)
192226
New to v1.2, we now include the ability to filter on properties outside of partition and row keys. Please note that this filtering occurs outside of table storage, so please consider using at least the partition key for best results.
193227

0 commit comments

Comments
 (0)