亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

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

實體框架無法向下加載列表2級

實體框架無法向下加載列表2級

C#
瀟瀟雨雨 2021-04-04 12:14:46
我具有以下模型結構:技能意圖(SkillId的外鍵)技巧(IntentId的外鍵)插槽(UtteranceId的外鍵)意圖模型public class Intent    {        [Key]        public int Id { get; set; }            [ForeignKey("Skill")]        public int? SkillId { get; set; }            public string Description { get; set; }                   public virtual Skill Skill { get; set; }        public virtual List<Utterance> Utterances { get; set; }    }話語模型   public class Utterance    {        [Key]        public int Id { get; set; }            [ForeignKey("Intent")]        public int IntentId { get; set; }        public string Utterancetext { get; set; }                    public virtual Intent Intent { get; set; }        public virtual List<Slot> Slots { get; set; }    }插槽型號public class Slot{    [Key]    public int Id { get; set; }    [ForeignKey("Utterance")]    public int UtteranceId { get; set; }    public string SlotValue { get; set; }    public SlotDataTypes SlotDataType { get; set; }            public virtual Utterance Utterance { get; set; }}實體框架流利的API modelBuilder.Entity<Intent>()            .HasOptional(i => i.Skill)            .WithMany(sk => sk.Intents)            .HasForeignKey(i => i.SkillId);        modelBuilder.Entity<Utterance>()            .HasRequired(x => x.Intent)            .WithMany(x => x.Utterances)            .HasForeignKey(x => x.IntentId);        modelBuilder.Entity<Slot>()            .HasRequired(x => x.Utterance)            .WithMany(x => x.Slots)            .HasForeignKey(x => x.UtteranceId);在我的數據訪問服務中,我有一種方法應獲取“意圖”>“話語”>“插槽”。var intents = ctx.Intents.Include(x => x.Utterances).Include("Utterances.Slots").ToList(); //<-- utterances are populated, slots count is 0var utterances = ctx.Utterances.Include(x => x.Slots).ToList(); // utterances are populated, slots are populatedvar slots = ctx.Slots.ToList(); // slots are populated        return intents;我需要的第一個電話是讓我了解所有意圖,它們的相關發音以及與發音相關的位置。盡管數據庫中肯定有插槽,但說話總是在填充,但插槽始終為零,第二次調用證明了這一點,因為如果我只是直奔Utterances并包含Slot,我會重新獲得插槽。從Intent導航一直到Slots,我在哪里出錯?
查看完整描述

1 回答

  • 1 回答
  • 0 關注
  • 162 瀏覽

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號