Skip to content

FlatTable's.Map on a nested event property generates null-conditional member access resulting in compilation error #3643

Open
@migajek

Description

Please consider the following event:

public record MyEvent(Guid Id, ExtCompKey ItemId);

where ExtCompKey is a struct: public record struct ExtCompKey(string Identifier, int Key);

now when I try to Map it in the flat table projection:

Project<MyEvent>(m =>
{
    m.Map(x => x.ItemId.Key);
});

the code generation throws

System.InvalidOperationException: Compilation failures!

CS0023: Operator '?' cannot be applied to operand of type 'ExtCompKey'
...
case Marten.Events.IEvent<(redacted).MyEvent> event_MyEvent112:
                    operations.QueueSqlCommand("select public.mt_upsert_test1_myevent(?, ?);", event_MyEvent112.StreamId,
event_MyEvent112.Data.ItemId?.Key);
                    break;

the only workaround I found so far is to enrich the event with a direct accessor (public int ItmKey => ItemId.Key;) and use it in the Map expression

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions