I'm using AutoMapper for C# and I'm trying to convert a property value into a property name.
Consider the following:
public class ClassA
{
public string ParamA { get; set; }
public string ParamB { get; set; }
}
public class ClassB
{
public string Name { get; set; }
public string Val { get; set; }
}
I have a list of ClassB instances and I'm trying to convert the value of "Val" property from ClassB into the correct property of ClassA based on the value of "Name":
ClassB b1 = new ClassB() {Name = "ParamA", Val = "ValueA"};
ClassB b2 = new ClassB() {Name = "ParamB", Val = "ValueB"};
ClassB b3 = new ClassB() {Name = "ParamC", Val = "ValueC"};
List<ClassB> listB = new List<ClassB>() {b1, b2, b3};
So using listB I'm trying to create an object of type ClassA
with ParamA = "ValueA"
and ParamB = "ValueB"
, is it possible using AutoMapper or any other tool?