子查询生成sql语法错误 返回

SqlSugar 沟通中
2 659

8a60656a66ec841b61a5bedf9f39d5c2.png

(SELECT  [w].[Id] AS [Id] , [w].[RoutingId] AS [RoutingId] , [v].[RoutingName] AS [RoutingName] , [w].[BomVersion] AS [BomVersion] , COUNT([w].[Id]) AS [ComponentCount]   as id ,0 as sugarIndex FROM [EntityBom] [w]    INNER JOIN [EntityRouting] [v] ON ( [v].[Id] = [w].[RoutingId] ) WHERE ( [w].[ParentMaterialId] = N'08de3a3d-34b9-4127-8405-436505934deb' ) GROUP BY [w].[Id],[w].[RoutingId],[v].[RoutingName],[w].[BomVersion])

 UNION ALL  (SELECT  [w].[Id] AS [Id] , [w].[RoutingId] AS [RoutingId] , [v].[RoutingName] AS [RoutingName] , [w].[BomVersion] AS [BomVersion] , COUNT([w].[Id]) AS [ComponentCount]   as id ,1 as sugarIndex FROM [EntityBom] [w]    INNER JOIN [EntityRouting] [v] ON ( [v].[Id] = [w].[RoutingId] ) WHERE ( [w].[ParentMaterialId] = N'08de3a25-8e0f-44f5-880c-615a5054f8cd' ) GROUP BY [w].[Id],[w].[RoutingId],[v].[RoutingName],[w].[BomVersion])

 UNION ALL  (SELECT  [w].[Id] AS [Id] , [w].[RoutingId] AS [RoutingId] , [v].[RoutingName] AS [RoutingName] , [w].[BomVersion] AS [BomVersion] , COUNT([w].[Id]) AS [ComponentCount]   as id ,2 as sugarIndex FROM [EntityBom] [w]    INNER JOIN [EntityRouting] [v] ON ( [v].[Id] = [w].[RoutingId] ) WHERE ( [w].[ParentMaterialId] = N'08de3a28-9ef7-47d9-829d-ec1bbdd2d3a0' ) GROUP BY [w].[Id],[w].[RoutingId],[v].[RoutingName],[w].[BomVersion])

 UNION ALL  (SELECT  [w].[Id] AS [Id] , [w].[RoutingId] AS [RoutingId] , [v].[RoutingName] AS [RoutingName] , [w].[BomVersion] AS [BomVersion] , COUNT([w].[Id]) AS [ComponentCount]   as id ,3 as sugarIndex FROM [EntityBom] [w]    INNER JOIN [EntityRouting] [v] ON ( [v].[Id] = [w].[RoutingId] ) WHERE ( [w].[ParentMaterialId] = N'08de3a21-72bf-400f-835e-f342d1ee3378' ) GROUP BY [w].[Id],[w].[RoutingId],[v].[RoutingName],[w].[BomVersion])

 UNION ALL  (SELECT  [w].[Id] AS [Id] , [w].[RoutingId] AS [RoutingId] , [v].[RoutingName] AS [RoutingName] , [w].[BomVersion] AS [BomVersion] , COUNT([w].[Id]) AS [ComponentCount]   as id ,4 as sugarIndex FROM [EntityBom] [w]    INNER JOIN [EntityRouting] [v] ON ( [v].[Id] = [w].[RoutingId] ) WHERE ( [w].[ParentMaterialId] = N'08de3a3c-eddd-4c47-8e94-f3b8b4ddbf59' ) GROUP BY [w].[Id],[w].[RoutingId],[v].[RoutingName],[w].[BomVersion])


莫名其妙出来 as id,前面没有任何字段

热忱回答(2)

  • wnf0000 wnf0000 VIP0
    2025/12/30

    可能是个bug,BomGroupItem原来是struct类型,我改成class后正常了。

    0 回复
  • fate sta fate sta VIP0
    2025/12/30

    只能是类

    0 回复