Is there any tools/plugins that can generate "manual" mapping code in VS/Resharper. I.e. there are 2 classes (Foo & Bar) with the same properties set:
{
public string A { get; set; }
public int B { get; set; }
public decimal C { get; set; }
}
Is it possible to generate the following code somehow?
public Bar Create(Foo foo)
{
var bar = new Bar();
bar.A = foo.A;
bar.B = foo.B;
bar.C = foo.C;
return bar;
}
Avoid mapping tools like AutoMapper, EmitMapper, etc.
Yes, you can write a T4 template to scan the classes in your project and generate the desired code
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With