scala-automapper
scala-automapper copied to clipboard
Automapper doesn't map Seq[SourceClass] to Seq[TargetClass] without any errors
automap(Seq(SourceClass())).to[Seq[TargetClass]] === Seq.empty
Thanks for reporting this, the Automapper currently expects a case class as an input rather than any type (Seqs, Maps, etc). I will definitely have a look into making it support this use case as well when I get the chance because, intuitively, it should.
For now, you could simply wrap the source and target sequences in a case class and automap that as a workaround:
case class SourceWrapper(sources: Seq[SourceClass])
case class TargetWrapper(targets: Seq[TargetClass])
automap(SourceWrapper(Seq(SourceClass()))).to[TargetWrapper]
Not the neatest solution, but please let me know if this works for you in the meantime!
We have used a different workaround and we are happy with it :wink: :
Seq(SourceClass()).map(automap(_).to[TargetClass])
Oh yeah, that would work too. 👍