I have defined the following projection in my Event Store:
fromAll()
.when({
$any: function (s, e) {
if (e.eventType.indexOf('$') !== 0 &&
e.streamId.indexOf('$') !== 0 )
linkTo ('Non-SystemEvents', e);
}
})
When reading from the resulting stream using the following method, I get the correct number of events back, but they do not deserialize properly (I use the method in a loop with sliceSizes of 1000).
public ResolvedEvent[] PerformReadFromStream(string streamName, int startPosition, int sliceSize, out int endPosition, out bool isEndOfStream)
{
EnsureConnection();
var resolvedEvents = new List<ResolvedEvent>();
var nextPosition = startPosition;
var slice = eventStoreConnection.ReadStreamEventsForward(streamName, nextPosition, sliceSize, false);
resolvedEvents.AddRange(slice.Events.Where(EventRequirements));
endPosition = slice.NextEventNumber;
isEndOfStream = slice.IsEndOfStream;
return resolvedEvents.ToArray();
}
The ResolvedEvent.Event.EventType is “$>” for all of these stream events, which looks suspciously like a pointer to me.
However, when I change the code to read using ReadAllEventsForward, the ResolvedEvents parse just fine.
public ResolvedEvent[] PerformRead(Position startPosition, int sliceSize, out Position endPosition, out bool isEndOfStream)
{
EnsureConnection();
var resolvedEvents = new List<ResolvedEvent>();
var nextPosition = startPosition;
var slice = eventStoreConnection.ReadAllEventsForward(nextPosition, sliceSize, false);
resolvedEvents.AddRange(slice.Events.Where(EventRequirements));
endPosition = slice.NextPosition;
isEndOfStream = slice.IsEndOfStream;
return resolvedEvents.ToArray();
}
I have built this projection on two different EventStores (one with 3 million events, one with 7 million events), and I get the same issue in both places. Is there something obviously wrong with my approach?