2

I have a following mapping in Automapper

.ForMember(d => d.Comment1, opt => opt.MapFrom(src => src.Comments?.FirstOrDefault(c => c.Type == "COMMENT1")?.Text))

But I am able to figure a way around the error

an expression tree lambda cannot contain a null propagating operator

Is there a simple way for doing this?

atiyar
  • 7,762
  • 6
  • 34
  • 75
Anand
  • 1,387
  • 2
  • 26
  • 48
  • That null check is built in with AM, just remove it. – Lucian Bargaoanu Feb 25 '21 at 18:23
  • Oh, I see - Thanks so much! – Anand Feb 25 '21 at 18:25
  • Does this answer your question? [Automapper 8 - An expression tree lambda may not contain a null propagating operator](https://stackoverflow.com/questions/54036296/automapper-8-an-expression-tree-lambda-may-not-contain-a-null-propagating-oper) – Rami A. Jul 21 '23 at 21:00

0 Answers0