I want to di initialization only for those classes they are mapped not necesserily 1:1 to dto object class.
I need this in order to generate valid XML file without empty tags (this would be the case if I put ...=new()
on each my POCO class and subclass objects)
So if my dto object contains for example:
public class Dto
{
public string? Name {get;set;}
public Foo? Foo {get;set}
public Bar? Bar {get;set}
}
and I have mapping something like:
var model = new Invoice();
var dto = new Dto();
model.ContractDocumentReference!.Id = dto.Foo.RequestId;
//for example lets say this is a nullable int
model.OrderReference!.Name= dto.Bar.CitizenName;
//have some value "John"
Can I somehow dynamically initialize only OrderReference
(because only Bar.CitizenName has actually a value) through reflection?
Is there any other approach? Definitely I would need a map when I initialize some class and when I dont (based on dto class object)
Aucun commentaire:
Enregistrer un commentaire