联表查询出现标识符过长问题 返回

求助
6 88
var query1 = Client.Queryable<PointView>().Where(it => it.TableName == tableName);
var query2 = Client.Queryable<PointView>().AS(tableName);
if(conditionals!=null && conditionals.Count > 0)
{
    query2 = query2.Where(conditionals);
}
query2 = query2.Select("PK_ID as Id");

var query = Client.Queryable(query1, query2, (p1, p2) => p1.Id == p2.Id).Select<PointView>("p1.*");
IList<PointView> points = query.ToList();

以上代码中 query1.ToList(),query2.ToList()正常执行,query.ToList()报错:“ORA-00972: 标识符过长”

tableName = "PS_MANHOLEPOINT_DZPS"

List<IConditionalModel> conditionals = new List<IConditionalModel>();

            conditionals.Add(new ConditionalModel { FieldName = "Road_Name", FieldValue = "青年路", ConditionalType = ConditionalType.Equal });

            conditionals.Add(new ConditionalModel { FieldName = "Manhole_Category", FieldValue = "雨水", ConditionalType = ConditionalType.Equal });

生成的SQL如下:

SELECT p1.* FROM  (SELECT "ID","CODE","X_COOR","Y_COOR","CATEGORY","POINTTYPE","TABLENAME","WKT" FROM "POINT_VIEW"  WHERE ( "TABLENAME" = :TableName0Join0 )) p1  Inner JOIN  (SELECT PK_ID as Id FROM "PS_MANHOLEPOINT_DZPS"  WHERE   Road_Name = :ConditionalRoad_Name0Join1   AND Manhole_Category = :ConditionalManhole_Category1Join1   ) p2   ON ( "P1"."ID" = "P2"."ID" )

错误出现原因疑似::ConditionalManhole_Category1Join1 过长


热忱回答6

  • 这个是SQL中的列名或者表名长度超过ORACLE限制引的,你看看ORACLE有没有设置的地方 或者修改列或者表的长度取个短点的名字

    0 回复
  • AOP可以打印SQL

    0 回复
  • @fate stay night:经检查 字段没有超长度,是预编译SQL的参数超长 即 Manhole_Category = :ConditionalManhole_Category1Join1 中的:ConditionalManhole_Category1Join1 超长了

    0 回复
  • @君莫忧:这个没办法你要想办法短一点

    0 回复
  • 参数也是根据你的列和表名来取的

    0 回复
  • @fate stay night:已经解决了,方案如下:


    360截图1700102110098125.png



    0 回复

版块

学习文档

最新会员

发布达人

回贴达人