第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

EFCodeFirst:我應(yīng)該初始化導(dǎo)航屬性嗎?

EFCodeFirst:我應(yīng)該初始化導(dǎo)航屬性嗎?

C#
慕運維8079593 2019-07-09 14:29:58
EFCodeFirst:我應(yīng)該初始化導(dǎo)航屬性嗎?我看過一些書編程實體框架代碼首先Julia Lerman)在沒有初始化導(dǎo)航屬性的情況下定義它們的域類(Poco),如下所示:public class User{     public int Id { get; set; }     public string UserName { get; set; }     public virtual ICollection<Address> Address { get; set; }     public virtual License License { get; set; }}其他一些書籍或工具(例如實體框架電動工具)當生成pocos初始化類的導(dǎo)航屬性時,如下所示:public class User{     public User()     {         this.Addresses = new IList<Address>();         this.License = new License();     }     public int Id { get; set; }     public string UserName { get; set; }     public virtual ICollection<Address> Addresses { get; set; }     public virtual License License { get; set; }}問題1:哪個更好?為什么?贊成與反對?編輯:public class License{     public License()     {         this.User = new User();     }     public int Id { get; set; }     public string Key { get; set; }     public DateTime Expirtion { get; set; }     public virtual User User { get; set; }}問題2:在第二種方法中,如果“License”類也引用了“user”類,則會出現(xiàn)堆棧溢出。這意味著我們應(yīng)該有單向的參考。(?)我們應(yīng)該如何決定應(yīng)該刪除哪個導(dǎo)航屬性?
查看完整描述

3 回答

  • 3 回答
  • 0 關(guān)注
  • 549 瀏覽

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學(xué)習(xí)伙伴

公眾號

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號