Hi I am just getting started with things and was doing one test to see how you would retrieve events of a certain type.
According to Greg Youngs blog “*bytype projection built into the Event Store that does this to $et-{typename} that is optimized.” *
Based on this I assume I can retrieve all events for a certain type using ‘$et-[typename]’ as the stream name. However when I try this I get ‘Stream-Not-Found’
I am using the ‘ReadStreamEventsBackward’ method try this. Am I doing something wrong or did I misunderstand something?
I have enabled projections via “EventStore.SingleNode.exe -run-projections”
Here is the code I was using to test this as well (in case it helps)
public void TestSaveSimpleEvent()
{
using (var connection = EventStore.ClientAPI.EventStoreConnection.Create(ConnectionSettings.Create()))
{
connection.Connect(endpoint);
string streamId = "TestStream";
TestEvent testEvent = new TestEvent()
{
TestId = Guid.NewGuid(),
TestName = "Some Data"
};
string jsonEvent = Newtonsoft.Json.JsonConvert.SerializeObject(testEvent);
byte[] eventRawBytes = Encoding.UTF8.GetBytes(jsonEvent);
var metaData = new EventMetaData
{
MessageHeader = testEvent.Header,
TimeStamp = testEvent.Timestamp,
GroupId = streamId
};
string jsonMetaData = Newtonsoft.Json.JsonConvert.SerializeObject(metaData);
byte[] metaDataRawBytes = Encoding.UTF8.GetBytes(jsonMetaData);
EventData eventData = new EventData(testEvent.EventId, testEvent.GetType().FullName, true, eventRawBytes,
metaDataRawBytes);
connection.AppendToStream(streamId, ExpectedVersion.Any, this.GetEventData(testEvent, streamId));
}
}
public void TestRetreiveEventByType()
{
using (var connection = EventStore.ClientAPI.EventStoreConnection.Create(ConnectionSettings.Create()))
{
connection.Connect(endpoint);
// I always get SliceReadStatus.StreamNotFound
var streamData = connection.ReadStreamEventsBackward("$et-" + typeof(TestEvent).FullName, 1,
1, false);
if (streamData.Status == SliceReadStatus.Success)
{
Console.WriteLine("Yay found something");
}
}
}