MappingGenerator
MappingGenerator copied to clipboard
Conditional mappings based on the Case/Specified flags
Hi, I'm using newtonjson with a rather obscure feature for Updating
public class UpdateDTO
{
public string? TestString = null;
public bool TestStringSpecified; // true if specified in json
}
Ideally,the mapping generated would be like this
static void Update (UpdateDTO u, Target target)
{
if (u.TestStringSpecified) target.TestString = u.TestString;
}
I'm wondering if mapping generator can generate this kind of mapping code, or is there a better way?
Hi,
It looks like a custom mapping logic but I came across on a similar approach while working with protobuf. I think it's wort to implement it but I can't promise any date, right now I'm busy with #133