Home:ALL Converter>Storing multiple fields of address in entity class

Storing multiple fields of address in entity class

Ask Time:2021-11-03T14:35:19         Author:Shruti sharma

Json Formatter

I need to store multiple addresses, like address1 , address2 and zipcode etc. Should I declare all the fields individually?

for instance:

class A{
      // many fields
     Address1:string;
     Address2:string;
     zipCode:number;
     city:String;
   }

or is there any better way to declare them in entity class? I have been told creating entity classes is the best practice.

enter image description here

Author:Shruti sharma,eproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/69820554/storing-multiple-fields-of-address-in-entity-class
morsor :

If only the addresses are multiple, it seems you have this situation:\nclass A {\n AddressList: string[];\n zipCode: number;\n city: String;\n}\n",
2021-11-03T07:25:39
androidavid :

Have you tried something like this?\nclass Address {\n//...\n zipCode: string;\n city: string; \n// ...\n}\n\nclass A {\n addresses: Address[]\n}\n",
2021-11-03T07:14:31
yy