public static async Task <ISequentialStore <T> > Create(IKeyValueStore <byte[], T> entityStore, string entityName, long defaultHeadOffset) { Preconditions.CheckNotNull(entityStore, nameof(entityStore)); Preconditions.CheckNonWhiteSpace(entityName, nameof(entityName)); Option <(byte[] key, T value)> firstEntry = await entityStore.GetFirstEntry(CancellationToken.None); Option <(byte[] key, T value)> lastEntry = await entityStore.GetLastEntry(CancellationToken.None); long MapLocalFunction((byte[] key, T) e) => StoreUtils.GetOffsetFromKey(e.key); long headOffset = firstEntry.Map(MapLocalFunction).GetOrElse(defaultHeadOffset); long tailOffset = lastEntry.Map(MapLocalFunction).GetOrElse(defaultHeadOffset - 1); var sequentialStore = new SequentialStore <T>(entityStore, entityName, headOffset, tailOffset); return(sequentialStore); }