据我所知,我应该在我的SQL数据库Commits表的Payload列中显示JSON,但是我有一个很长的十六进制字符串。
我的电汇代码是根据样本进行以下编辑:
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();
}
知道如何获取JSON并使调试更容易吗?
答案 0 :(得分:2)
只需创建以下视图:
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]
您可以使用LIKE
列上的Payload
查询您的活动商店以查找特定活动。
答案 1 :(得分:1)
与此类似的查询将获取Payload列的字符串内容:
Commits
.Select(c => System.Text.Encoding.UTF8.GetString(c.Payload.ToArray()))
.ToList();