表达式树可能不包含来自 AutoMapper 映射的输出参数变量声明

An expression tree may not contain an out argument variable declaration AutoMapper map from

我有以下映射 (AutoMapper Version="10.1.1"):

CreateMap<FooClass, BarClass>()
    .ForMember(
        dest => dest.Status, 
        opt => opt.MapFrom(
            src => Enum.TryParse(src.Status ?? string.Empty, out Status result) ? result : Status.TEST_READY)
    );

但是出现错误:

CS8198: An expression tree may not contain an out argument variable declaration

知道如何在无需创建自定义解析器的情况下完成此操作吗?

谢谢

尝试在 lambda 中添加 src 和目标 (dest)

CreateMap<FooClass, BarClass>()
    .ForMember(
        dest => dest.Status, 
        opt => opt.MapFrom(
            (src, dest) => Enum.TryParse(src.Status ?? string.Empty, out Status result) ? result : Status.TEST_READY)
    );