Пример #1
0
        public StreamState Resolve(DbDataReader reader)
        {
            var id        = reader.GetFieldValue <T>(0);
            var version   = reader.GetFieldValue <int>(1);
            var typeName  = reader.IsDBNull(2) ? null : reader.GetFieldValue <string>(2);
            var timestamp = reader.GetValue(3).MapToDateTime();
            var created   = reader.GetValue(4).MapToDateTime();

            Type aggregateType = null;

            if (typeName.IsNotEmpty())
            {
                aggregateType = _events.AggregateTypeFor(typeName);
            }

            return(StreamState.Create(id, version, aggregateType, timestamp.ToUniversalTime(), created));
        }
Пример #2
0
        public async Task <StreamState> ResolveAsync(DbDataReader reader, CancellationToken token)
        {
            var id = await reader.GetFieldValueAsync <T>(0, token).ConfigureAwait(false);

            var version = await reader.GetFieldValueAsync <int>(1, token).ConfigureAwait(false);

            var typeName = await reader.IsDBNullAsync(2, token).ConfigureAwait(false) ? null : await reader.GetFieldValueAsync <string>(2, token).ConfigureAwait(false);

            var timestamp = await reader.GetFieldValueAsync <object>(3, token).ConfigureAwait(false);

            var created = await reader.GetFieldValueAsync <object>(4, token).ConfigureAwait(false);

            Type aggregateType = null;

            if (typeName.IsNotEmpty())
            {
                aggregateType = _events.AggregateTypeFor(typeName);
            }

            return(StreamState.Create(id, version, aggregateType, timestamp.MapToDateTime().ToUniversalTime(), created.MapToDateTime()));
        }