Skip to content
This repository has been archived by the owner on Jan 16, 2022. It is now read-only.

Loosing properties #12

Closed
OmiCron07 opened this issue Mar 20, 2018 · 6 comments
Closed

Loosing properties #12

OmiCron07 opened this issue Mar 20, 2018 · 6 comments
Labels
enhancement New feature or request

Comments

@OmiCron07
Copy link

When using the MappginGenerator, I lose my properties UnitId/InventoryUnitId and Category/UnitCategory:

image

Is it possible to detect slight variation in property name or at least not overriding the entire method and keeping my unmatched properties?

@cezarypiatek
Copy link
Owner

I would like to keep mapping rules quite obvious and "detect slight variation in property name" could result in complicated logic and the outcome could be far away from expected for different use cases. The second option with not overriding entire method requires add some merging logic. I was thinking about adding option to assign default value for unmapped target fields which could help to spot places with naming discrepancy or missing fields. For now to avoid complete method overriding you can write line with assigning source to destination

public override void Convert(T1 source, T2 destination)
{
    destination = source;
}

and try to apply another code fix which comes with MaggingGenerator that create conversion (the bulb should appear in line with the assignment).

image

@OmiCron07
Copy link
Author

Ok, but the problem is maintainability. No way you generate the mapping once and never change it. Some properties will be added, some will be removed.

I can't imagine having to remove the code, writing target = source,, alt-enter, Generate, each time to update the mapping.

I know the problem is not trivial, but I need a tool to quickly generate mapping code and also, update the mapping efficiently.

What do you think?

@cezarypiatek
Copy link
Owner

I don't see the problem with maintainability. In most cases you add or remove single field, so it's not big effort to apply this simple modification manually instead of regenerating the whole mapping. What if in the meantime somebody add custom, non-trivial mapping logic? How am I supposed to detect that and perform merging during regeneration? How to decide if this modification is still valid and should survive the regeneration?

@OmiCron07
Copy link
Author

If the target or source property is already used, skip it?

@cezarypiatek
Copy link
Owner

sounds simple, and if the method flow is simple (no conditional or loop statements) it could work. Anyway I think it should be registered as separated code fix - with the update purpose.

@cezarypiatek
Copy link
Owner

I'm not going to implement a synchronization mechanism. If you need a mapping code that is continuously synchronized with models, please take a look at OnBuild plugin (#79) that generates mapping code during the build.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants