With AutoMapper, I use a ValueResolver that returns a structure like this
struct MyStruct { public int propA; public int propB; public int propC; } class MyResolver : ValueResolver<MyViewModel, MyStruct> { protected override MyStruct ResolveCore(MyViewModel source) { ....return MyStruct data } }
I returned the structure because the matching rules are quite complex, and I could not write a custom resolver for each property, since they are related to each other.
So my idea was to do this in one resolver that returns a structure and uses itike this
AutoMapper.Mapper.CreateMap<MyViewModel, myData>() .ForMember(dest => dest.SomePropA, src => src.ResolveUsing<MyResolver>().propA)) .ForMember(dest => dest.SomePropB, src => src.ResolveUsing<MyResolver>().propB))
Unfortunately this does not work.
It looks like src.ResolveUsing<MyResolver>() does not return a structure
Any help is more than appreciated.
Thanks.
source share