Skip to content

Default Serialiser Settings Helper #1261

Description

@StuartFerguson

Ignore base domain event properties so they are not written to Event Store

var options = new JsonSerializerOptions
{
    TypeInfoResolver = new DefaultJsonTypeInfoResolver
    {
        Modifiers =
        {
            typeInfo =>
            {
                if (typeInfo.Type == typeof(MyDto))
                {
                    var prop = typeInfo.Properties
                        .FirstOrDefault(p => p.Name == "AggregateId");

                    if (prop != null)
                        prop.ShouldSerialize = (_, _) => false;
                }
            }
        }
    }
};

Property Names are

  • AggregateId
  • AggregateVersion
  • EventId
  • EventNumber
  • EventTimestamp
  • EventType

Json Input and Output formatting

var options = new JsonSerializerOptions
{
    PropertyNamingPolicy = new SnakeCaseNamingPolicy()
};

This only covers System.Text.Json at the moment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions