error ♡
How do I make a good DTO of lot's of classes.
yo, i have a question, so I have a C# class, which basically has a bunch of classes as it's fields.
Class King {
public A AClassObj;
public B BClassObj
}
and I will only ever set one of these properties, that is King.AclassObj = setAClass.
Context: basically i'm needed to list down all these classes as properties because swagger autogen can pass my classes to the client and generate code for me.
In my use case, king will only contain one non null field, Is there a better way to do this.
The problem with this that i'm facing right now is, Will parsing this King Object on my service, I will have to check/parse each field with it's associated type and then set using that type correctly (lots of switch statements). and I don't wanna use reflection cause it's slow and also doesn't work for me.
Anyone up to sit down and understand this and help me out lol?
16 replies