AOT模式下排序报错 返回

SqlSugar 处理完成
12 2169
该叫什么 sxx 发布于2023/11/30
悬赏:0 飞吻

AOT模式下排序报错,无论是:OrderBy("DEPT_PRIO");OrderBy(a=>a.DEPT_PRIO) 或  OrderBy(a=>new {a.DEPT_PRIO} )    都报错,提示: need is a class,and can new()。

热忱回答12

  • fate sta fate sta VIP0
    2023/11/30

    截图完整代码

    0 回复
  • fate sta fate sta VIP0
    2023/11/30

    你是不是没用class操作

    0 回复
  • sxx sxx VIP0
    2023/11/30

    @fate sta: db.Queryable<Model.SYS_DEPT>().OrderBy(a => a.DEPT_PRIO, SqlSugar.OrderByType.Asc).ToList()

    0 回复
  • fate sta fate sta VIP0
    2023/11/30

    我验证一下

    0 回复
  • fate sta fate sta VIP0
    2023/11/30

    我加orderby成功的啊,你是什么数据库

    0 回复
  • fate sta fate sta VIP0
    2023/11/30

    Model.SYS_DEPT 这个类发出来看一下

    0 回复
  • sxx sxx VIP0
    2023/11/30

    @fate sta:sql server 

    [SqlSugar.SugarTable("SYS_DEPT")]

    public class SYS_DEPT

    {

        public SYS_DEPT()

        { }

        #region Model

        private string _dept_code;

        private string _pare_code;

        private string _dept_name;

        private string _server_name;

        private int? _remote_dept;

        private string _dept_emai;

        private int? _dept_prio;

        private string _company_name;

        private string _user_company;


        /// <summary>

        /// 部门代码

        /// </summary>

        [SqlSugar.SugarColumn(IsPrimaryKey = true)]

        public string DEPT_CODE

        {

            set { _dept_code = value; }

            get { return _dept_code; }

        }

        /// <summary>

        /// 上级部门代码

        /// </summary>

        public string PARE_CODE

        {

            set { _pare_code = value; }

            get { return _pare_code; }

        }

        /// <summary>

        /// 部门名称

        /// </summary>

        public string DEPT_NAME

        {

            set { _dept_name = value; }

            get { return _dept_name; }

        }

        /// <summary>

        /// 部门简称

        /// </summary>

        public string DEPT_SHORTNAME { get; set; }

        /// <summary>

        /// 服务器名称

        /// </summary>

        public string SERVER_NAME

        {

            set { _server_name = value; }

            get { return _server_name; }

        }

        /// <summary>

        /// 是否远程部门

        /// </summary>

        public int? REMOTE_DEPT

        {

            set { _remote_dept = value; }

            get { return _remote_dept; }

        }

        /// <summary>

        /// 部门邮箱

        /// </summary>

        public string DEPT_EMAI

        {

            set { _dept_emai = value; }

            get { return _dept_emai; }

        }

        public string DEPT_PHON { get; set; }

        /// <summary>

        /// 部门排序号

        /// </summary>

        public int? DEPT_PRIO

        {

            set { _dept_prio = value; }

            get { return _dept_prio; }

        }

        /// <summary>

        /// 所属机构名称

        /// </summary>

        [SqlSugar.SugarColumn(IsIgnore = true)]

        public string USER_COMPANY_NAME

        {

            set { _company_name = value; }

            get { return _company_name; }

        }

        /// <summary>

        /// 所属机构代码

        /// </summary>

        public string USER_COMPANY

        {

            set { _user_company = value; }

            get { return _user_company; }

        }

        /// <summary>

        /// 部门路径

        /// </summary>

        public string dept_path { get; set; }

        /// <summary>

        /// 部门类型

        /// </summary>

        public string type_code { get; set; }

        /// <summary>

        /// 部门层级

        /// </summary>

        public int levelKind { get; set; }

        /// <summary>

        /// 组织管理员

        /// </summary>

        public string DEPT_MGR { get; set; }

        /// <summary>

        /// 组织地址

        /// </summary>

        public string DEPT_ADDR { get; set; }


        public string ServerId { get; set; }

        #endregion Model


        /// <summary>

        /// 部门路径名称(简称)

        /// </summary>

        [SqlSugar.SugarColumn(IsIgnore = true)]

        public string dept_pathName { get; set; }

    }


    0 回复
  • fate sta fate sta VIP0
    2023/11/30

    aot_test-master.rar


    你写个能重现的,在这个基础上改

    0 回复
  • fate sta fate sta VIP0
    2023/11/30

    删掉Obj 和 bin上传

    0 回复
  • fate sta fate sta VIP0
    2023/11/30

    我这边不能重现,SQLSEVER ORDRBY也试了

    0 回复
  • sxx sxx VIP0
    2023/12/1

    @fate sta:非常感谢,问题找到原因了,是因为Model 在另外的工程,在 rd.xml文件中添加后就没问题了。

    image.png

    0 回复
  • 对的 提示这个基本是要rd加启动项名

    0 回复