Join GitHub today
GitHub is home to over 36 million developers working together to host and review code, manage projects, and build software together.Sign up
Issues using AutoMapper with DataRow Descendants #228
Hi there. I'm new to AutoMapper and so far it seems like a very promising library. I am trying to use it as a solution to copy the property values from one DataRow descendant to another (using strongly-typed datasets). The problem I am having is that, regardless of the ForMember/MapFrom combinations I use, the source DataRow values seem to be copied directly to the destination DataRow properties. If I use a simple object with all the same code, things work properly.
I've created a sample project that reproduces this:
The relevant code is in Form1.cs. The project uses the AdventureWorks DB. This is pretty simple to reproduce. As I indicated I'm new to AutoMapper so maybe I'm doing something wrong here.
Thanks in advance! I'd love to be able to use AutoMapper here as it seems like it could save a lot of code.
I've updated my example on Github with the solution for this. It is not an issue with AutoMapper. AutoMapper was doing its job and copying the ItemArray property found in the ancestor DataRow. This was causing properties to come over exactly, appearing to disregard the .ForMember() and .MapFrom() options specified. Using opt.Ignore() for the ItemArray member fixes this.