导航更新时第三级是一对一时异常,第三级更新一对多时正常 返回

SqlSugar 沟通中
2 308
该叫什么 π 发布于2026/8/10
悬赏:0 飞吻

异常信息Unknown column 'Name' in 'field list'

配置一对一时
await _db.UpdateNav(data).Include(x => x.ConfigList).ThenInclude(x => x.Location).ExecuteCommandAsync()

改为一对多时
await _db.UpdateNav(data).Include(x => x.ConfigList).ThenInclude(x => x.Locations).ExecuteCommandAsync()

热忱回答(2)

  • fate sta fate sta VIP0
    2026/8/10

    提完实体类。

    0 回复
  • π π VIP0
    2026/8/11

    @fate sta:

    public class EntityBaseId 
    {
        /// <summary>
        /// 雪花Id
        /// </summary>
        [SugarColumn(ColumnName = "Id", ColumnDescription = "主键Id", IsPrimaryKey = true, IsIdentity = false)]
        public long Id { get; set; }
    
        /// <summary>
        /// 版本
        /// </summary>
        [SugarColumn(IsEnableUpdateVersionValidation = true)]
        public long Ver { get; set; }
    }
    
    public class ViewConfig : EntityBaseId
    {
        [SugarColumn(IsNullable = true)]
        public string? BackgroundColor { get; set; }
    
        public string Width { get; set; } = string.Empty;
        
        public string Height { get; set; } = string.Empty;
    
        /// <summary>
        /// 全屏
        /// </summary>
        [SugarColumn(IsNullable = true)]
        public bool? FullScreen { get; set; }
    
        /// <summary>
        /// 组件配置列表
        /// </summary>
        [Navigate(NavigateType.OneToMany,nameof(ConfigType.ChartViewConfigId),nameof(Id))]
        public List<ConfigType> ConfigList { get; set; }
    }
    
    
    public class ConfigType
    {
        [SugarColumn(ColumnName = "Id", ColumnDescription = "主键Id", IsPrimaryKey = true, IsIdentity = false)]
        public string Id { get; set; } = string.Empty;
        [SugarColumn(IsNullable = true)]
        public string? Icon { get; set; }
        
        public string? ComponentKey { get; set; }
    
        public long? ChartViewConfigId { get; set; }
        
        [Navigate(NavigateType.OneToOne,nameof(Id),nameof(ConfigLocation.TypeId))]
        public ConfigLocation Location { get; set; }     
    
        [Navigate(NavigateType.OneToMany, nameof(ConfigLocation.TypeId),nameof(Id))]
        public List<ConfigLocation> Locations { get; set; }
    
    }
    
    public class ConfigLocation : EntityBaseId
    {
        public double X { get; set; }
        public double Y { get; set; }
        [SugarColumn(IsNullable = true)]
        public double? Z { get; set; }
        [SugarColumn(IsNullable = true)]
        public double? Left { get; set; }
        [SugarColumn(IsNullable = true)]
        public double? Right { get; set; }
    
        public double W { get; set; }
        public double H { get; set; }
    
        public string TypeId { get; set; }
    }
    
    
    实体大致如上


    0 回复