c# - Dependency Injection and Entities -


i have 2 classes , have 1 many relationship shown below

public class user {     public string name{get;set;}     public ilist<address> addresses{get;set} }  public class address {    public string streetaddress{get;set;}    public user user{get;set;} } 

to add address user need initiate addresses property in user constructor as

public user() {    this.addresses=new list<address>();  } 

is scenario candidate use di initiate list or should initiate address list in constructor shown.

if the address data required construct instance of user, may candidate di. if's matter of making sure list instantiated, code correct as-is.


Comments

Popular posts from this blog

java - Oracle EBS .ClassNotFoundException: oracle.apps.fnd.formsClient.FormsLauncher.class ERROR -

c# - how to use buttonedit in devexpress gridcontrol -

HTML pattern attribute for email validation -