Deep Cloning #420
Deep Cloning
#420
-
Hi everyone, Could mapperly be used to deep clone one object? [Mapper(UseDeepCloning = true)]
public partial class DocumentMapper
{
public partial Document Map(Document doc);
}
public class Document
{
public int Id { get; set; }
public string Name { get; set; }
public string Description { get; set; }
} The code generated is like this: public partial global::ConsoleAppMapperly.Document? Map(global::ConsoleAppMapperly.Document? doc)
{
if (doc == null)
return default;
var target = new global::ConsoleAppMapperly.Document();
target.Name = doc.Name;
target.Description = doc.Description;
return target;
} The |
Beta Was this translation helpful? Give feedback.
Answered by
latonz
May 10, 2023
Replies: 1 comment 9 replies
-
That's strange I can't replicate this. Which version of mapperly are you using? // Assuming nullable is disabled
public partial class DocumentMapper
{
public partial global::Riok.Mapperly.Sample.Document? Map(global::Riok.Mapperly.Sample.Document? doc)
{
if (doc == null)
return default;
var target = new global::Riok.Mapperly.Sample.Document();
target.Id = doc.Id;
target.Name = doc.Name;
target.Description = doc.Description;
return target;
}
} |
Beta Was this translation helpful? Give feedback.
9 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The fix for this bug is merged into main but not yet released. A preview release will be published in the upcoming days including the fix in question.