public Task <IEnumerable <T> > GetFromSequenceNumber <T>(StreamEntityType entityType, ulong sequenceNumberStart = 0, ulong sequenceNumberEnd = ulong.MaxValue) where T : StreamEntityBase { var entries = _db.HashGetAll($"{_databaseName}-{entityType}"); if (entries != null) { var items = new List <T>(); foreach (var entry in entries) { try { var item = StreamEntityBase.FromProtoBufByteArray(entry.Value) as T; if (item.SequenceNumber >= sequenceNumberStart && item.SequenceNumber <= sequenceNumberEnd) { items.Add(item); } } catch (Exception ex) { } } return(Task.FromResult(items.AsEnumerable())); } else { return(Task.FromResult <IEnumerable <T> >(null)); } }
public Task <T> GetById <T>(StreamEntityType entityType, string id) where T : StreamEntityBase { var data = _db.HashGet($"{_databaseName}-{entityType}", id); if (data.HasValue) { try { return(Task.FromResult(StreamEntityBase.FromProtoBufByteArray(data) as T)); } catch (Exception ex) { return(Task.FromResult <T>(null)); } } else { return(Task.FromResult <T>(null)); } }
public Task <IEnumerable <T> > GetAll <T>(StreamEntityType entityType) where T : StreamEntityBase { var entries = _db.HashGetAll($"{_databaseName}-{entityType}"); if (entries != null) { var items = new List <T>(); foreach (var entry in entries) { try { items.Add(StreamEntityBase.FromProtoBufByteArray(entry.Value) as T); } catch (Exception ex) { } } return(Task.FromResult(items.AsEnumerable())); } else { return(Task.FromResult <IEnumerable <T> >(null)); } }