AutoMapper still does the generic work of mapping from objects. However, to fill in extra data, sometimes you need an async source.
- Aggregate domain objects that are built from different sources of data.
- The biggest source of non-database data is a cache, which could be all async!
- Fitting a domain on top of an aging database schema is hard. So lots of code may be required to adapt this schema to a domain. Other async sources may be required.
Fitting the glue of building/mapping a domain object from data into a AutoMapper mapping just makes sense.
How does it work?
IMapperin your code.
IAsyncMappingfor your desired mappers.
AsyncMapperwill fallback to
IMapperwhen an instance of
IAsyncMappingfor the requested map isn't found.
IAsyncMapperwill do a loop for collections like
IAsyncCollectionMappingfor optimized handling of
IEnumerablemappings for batching async operations.
Components in a Toy Sample
Profileclasses for organization: MappingProfile.cs
AutoMapperin your async mappers if needed like so: SourceClassMapping.cs
- Glue together! Program.cs
- Optimize/cache reflection operations.
- Support more than
- Support using Dependency Injection other than through