hmfl

导航

 

//排序-根据实际情况修改,注意这里不要指定a.的别名,不然会造成PageList方法的错误找不到排序列
//sql.OrderBy("a.CreateTime Desc");
//sql.OrderBy("a.Id");
sql.OrderBy("CreateTime Desc");
sql.OrderBy("Id");
response = await repository.PageList(sql, t.obj.PageIndex, t.obj.PageSize);
不然会提示

返回时会异常

  • Message:无法绑定由多个部分组成的标识符 "a.CreateTime"。
    无法绑定由多个部分组成的标识符 "a.Id"。
    用MSSQL追踪代码转换后执行的结果
    exec sp_executesql N'SELECT * FROM (SELECT ROW_NUMBER() OVER (ORDER BY a.CreateTime Desc
    , a.Id) peta_rn, peta_inner.* FROM (SELECT DISTINCT a.*
    FROM Sales_Order_Exchange a
    LEFT JOIN Sales_Order_Exchange_Detail b
    ON a.Id=b.OrderId
    WHERE (a.ShopId=''b6fa1418-82fb-4ad3-9445-2bdc1b667981'')
    AND (a.IsDel=0)
    ) peta_inner) peta_paged WHERE peta_rn > @0 AND peta_rn <= @1',N'@0 bigint,@1 bigint',@0=0,@1=10

上面报错a.CreateTime,因为是用Peta框架自动生成了别名peta_inner

posted on 2021-11-19 20:26  hmflhmfl  阅读(92)  评论(0编辑  收藏  举报