I am working on a web solution that uses .NET 6 framework as backend with EventFlow (Event-sourcing & CQRS). All of my events are store in the table EventEntity :
I would like to add additional information in the Metadata attribute. I read the documentation but I don't understand about how to do it :
The documentation :
The Metadata attribute is in JSON format :
Any help would be appreciated
I've found the anwser.
By the use of IMetadataProvider
Example :
public static readonly string UserNameKey = "username";
public static readonly string UserAccountKey = "useraccount";
public IEnumerable<KeyValuePair<string, string>> ProvideMetadata<TAggregate, TIdentity>(TIdentity id, IAggregateEvent aggregateEvent, IMetadata metadata)
where TAggregate : IAggregateRoot<TIdentity>
where TIdentity : IIdentity
{
var userAccount = this.identityService.GetUserIdentity();
var userName = this.identityService.GetUserName();
yield return new KeyValuePair<string, string>(UserNameKey, userName);
yield return new KeyValuePair<string, string>(UserAccountKey, userAccount);
}