Automapper: Using the structure returned by a custom resolver

后端 未结 1 1826
遥遥无期
遥遥无期 2021-01-13 12:17

With AutoMapper, I am using a ValueResolver that returns a structure like this

struct MyStruct
{
        public int propA;
        public int propB;
                 


        
相关标签:
1条回答
  • 2021-01-13 13:02

    By using FromMember you can pass a property from the source to your ValueResolver.

    You can use something like this:

    .ForMember(dest => dest.SomePropA, opt=> opt.ResolveUsing<MyResolver>().FromMember(src => src.propA))
    

    If you don't specify FromMember, AutoMapper will pass the source to your ValueResolver.

    0 讨论(0)
提交回复
热议问题