树形查询 totree()的问题 返回

SqlSugar
1 29
//接口
public List<TBC_FACTORYEntity> GetFactoryList(string factoryID = "")
        {
            var db = DBContext<TBC_FACTORYEntity>.GetDBContext;
            try
            {
                var data = db.DataBase.Queryable<TBC_FACTORYEntity>()
                   .ToTree(u => u.SonList, u => u.SUPERIOR_ID, "000");

                return data;
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
 //实体类
 namespace BLDataEntity
{
    /// <summary>
    /// 
    /// </summary>
    [SugarTable("TBC_FACTORY")]
    public class TBC_FACTORYEntity
    {
        [SugarColumn(IsPrimaryKey = true, IsIdentity = false)]
        public string FACTORY_ID { get; set; }
        /// <summary>
        /// 上级产线iD
        /// </summary>
        public string SUPERIOR_ID { get; set; }
        /// <summary>
        /// 工厂编号
        /// </summary>
        public string FACTORY_NO { get; set; }

        [SugarColumn(IsIgnore =true)]
        public List<TBC_FACTORYEntity>  SonList { get; set; }
    }
}
//postman返回的数据
{
    "flag": 0,
    "msg": null,
    "data": [
        {
            "factorY_ID": "000001",
            "superioR_ID": "000",
            "factorY_NO": "sss",
            "sonList": [
                {
                    "factorY_ID": "000001001",
                    "superioR_ID": "000001",
                    "factorY_NO": "sss",
                    "sonList": []
                }
            ]
        },
        {
            "factorY_ID": "000002",
            "superioR_ID": "000",
            "factorY_NO": "sss",
            "sonList": []
        }
    ]
}


数据库数据截图

微信图片_123.png

请问 根数据 000 为什么查不出来啊,怎么才能查出根数据,我用的5.0.0版本

热忱回答1

  • 老版本可能不支持 , 现在都 5.1.33了 

    0 回复