1
    Mapper.Map<Foo, Bar>(
      o,
      new MyType{
        IntProp = service.GetIntProp(o.someProp),
        StrProp = IntProp == 1 ? "Hello" : "World"
      },
      someOptions => {}
    )

Is there a way to just access the value of IntProp without creating a variable to hold MyType? I could just call the service again, but I am somehow concerned with performance.

Barak
  • 535
  • 6
  • 18

1 Answers1

1

A field initializer cannot reference the non-static field, method, or property. See this question for more details: Can properties inside an object initializer reference each other?

Community
  • 1
  • 1
Time Rider
  • 29
  • 6