EventStore only shows the hexadecimal string in the Payload column

As far as I can tell, I should show JSON in the "Payload" column in my SQL Commals table, but I have a long hexadecimal string.

My connection code matches the sample with the following changes:

private static IStoreEvents WireupEventStore() { return Wireup.Init() .LogToOutputWindow() .UsingInMemoryPersistence() .UsingSqlPersistence("EventStore") // Connection string is in app.config .WithDialect(new MsSqlDialect()) .EnlistInAmbientTransaction() // two-phase commit .InitializeStorageEngine() .UsingJsonSerialization() .HookIntoPipelineUsing(new[] { new AuthorizationPipelineHook() }) .UsingSynchronousDispatchScheduler() .DispatchTo(new DelegateMessageDispatcher(DispatchCommit)) .Build(); } 

Any idea how to get JSON and make debugging easier?

+2
source share
2 answers

Just create the following view:

 CREATE VIEW [dbo].[DeserializedCommits] AS SELECT [StreamId] ,[StreamRevision] ,[Items] ,[CommitId] ,[CommitSequence] ,[CommitStamp] ,[Dispatched] ,CAST([Headers] AS VARCHAR(MAX)) AS [Headers] ,CAST([Payload] AS VARCHAR(MAX)) AS [Payload] FROM [dbo].[Commits] 

You can request your event store for specific events using LIKE in the Payload column.

+2
source

A query like this will give you the string content of the Payload column:

 Commits .Select(c => System.Text.Encoding.UTF8.GetString(c.Payload.ToArray())) .ToList(); 
+1
source

All Articles