Simple Alternative to AutoMapper

Recently we had some troubles with AutoMapper after upgrading our core libraries (Xamling-Core) to Xamarin Unified. Our unit tests started failing.

There is more detail on that issue here:

In the meantime it left us scrambling for a replacement. Our entity cache and management system relies on mapping to ensure entity instances are the same no matter how you get it… a job for a mapper. Keep original entity in memory, any updates come in you copy the new data on to the in memory instance… all references are happy.

So we had a look around, and turns our – we don’t really use many of AutoMappers features. Great lib to be sure – but we are doing the most basic of mappings.

The solution was found on StackOverflow (naturally) posted by user Azerothian here.

We made a few little mods and made it available as part of the Xamling-Core library.



EDIT – it was pointed out by @JakeGinnivan that this would be slower than AutoMapper… keep that in mind for high usage scenarios. Shouldn’t be a problem in a mobile app, but worth keeping in mind – thanks Jake!

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s