public IEnumerable<SequenceIdStore> GetSequenceIdStores()
{
var schemas = SchemaTableProxy.QueryPartitions("0", "zzzzz");
var sequences = SequenceTableProxy.QueryPartitions("0", "zzzzz") ?? new List<TableEntityProxy<DynamicTableEntity>>();
var stores = new List<SequenceIdStore>();
foreach (var schema in schemas)
{
var sequence =
sequences.FirstOrDefault(x =>
String.Equals(schema.Entity.TableName, x.Entity[TableConstants.PartitionKey].StringValue,
StringComparison.InvariantCultureIgnoreCase));
if (sequence == null)
{
sequence = new TableEntityProxy<DynamicTableEntity>(new DynamicTableEntity(schema.PartitionKey, schema.RowKey, "",
new Dictionary<string, EntityProperty>()));
sequence.Entity.Properties.Add(PropertyFinalCachedId, new EntityProperty(schema.Entity.SeedValue));
SequenceTableProxy.Insert(sequence.Entity); //this could throw if another thread created after SequenceTableProxy.QueryPartitions was called above.
}
stores.Add(new SequenceIdStore
{
FinalCachedId = sequence.Entity.Properties[PropertyFinalCachedId].StringValue,
Schema = schema.Entity
});
}
return stores;
}