Convention for mapping collections to scalars via LINQ in Automapper

116 Views Asked by At

Automapper already does some nice convention stuff like mapping sub-properties by naming convention e.g. OrderTotal would map from Order.Total if such a property on a property existed.

I was wondering if there is a way to do a similar thing with LINQ operator names. For example if I had a collection IEnumerable<Appointment> called Appointments, it would be great if on my target type I had a property called AppointmentFirst of type Appointment and AutoMapper automagically called First().

Is there any way to do something like this currently?

1

There are 1 best solutions below

0
On

There is no support for such things out of the box. However you can achieve it by using custom type converters.