-
Is it possible to combine two models into one? Ignoring empty properties from the second model
|
Beta Was this translation helpful? Give feedback.
Answered by
latonz
Dec 12, 2023
Replies: 2 comments
-
Have you tried using existing target mappings. Not sure about the nullability behaviour. |
Beta Was this translation helpful? Give feedback.
0 replies
-
You can use existing target mappings (as mentioned by @TimothyMakkison) in combination with [Mapper(AllowNullPropertyAssignment = false)]
static partial class Mapper
{
public static partial void Merge(A source, B target);
}
// generates
public static partial void Merge(global::A source, global::B target)
{
if (source.V != null)
{
target.V = source.V;
}
if (source.V2 != null)
{
target.V2 = source.V2;
}
} |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
Zombach
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You can use existing target mappings (as mentioned by @TimothyMakkison) in combination with
AllowNullPropertyAssignment = false
, this should work to merge objects where all source properties are nullable.