问题
As far as I can tell I should have JSON showing in Payload column in my SQL database Commits table, however I have a long hexadecimal string.
My wireup code is as per the sample with the following edits:
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?
回答1:
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 than query your event store for specific events using LIKE
on Payload
column.
回答2:
A query similar to this one will get you the string content of the Payload column:
Commits
.Select(c => System.Text.Encoding.UTF8.GetString(c.Payload.ToArray()))
.ToList();
来源:https://stackoverflow.com/questions/15723678/eventstore-only-showing-hexadecimal-string-in-payload-column