Different results when reading from Stream versus reading AllEventsForward

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?

You need to skip any event where EventType.StartsWith("$")

You can resolve the pointers in the Client API, the reading methods all have “resolveLinkTos” as one of the options, see https://github.com/EventStore/EventStore/blob/dev/src/EventStore.ClientAPI/IEventStoreConnection.cs#L164 .
Setting this to true will populate the link and the event.

Does this do what you’re looking for?

James

He probably should not do this if he is reading from the $all stream though.

Herpy derp, disregard my last email.

This solved the problem. Guess I should have read the parameters a bit closer.

Thanks much!

Kerry