子查询使用SqlFunc.IIF和like查询是生成了两个相同的参数名导致报错了 返回

SqlSugar
3 150

image.png

生成SQL语句如下:

SELECT SUM(   (CASE
                   WHEN ([Total] = @Total0) THEN
                       @MethodConst1
                   ELSE
                       @MethodConst2
               END
              )
          ) AS [Waiting],
       SUM(   (CASE
                   WHEN ([Total] > @Total3) THEN
                       @MethodConst4
                   ELSE
                       @MethodConst5
               END
              )
          ) AS [Answered],
       COUNT(@MethodConst6) AS [Total],
       SUM([Total]) AS [ReplyTotal]
FROM
(
    SELECT
        (
            SELECT COUNT(*)
            FROM [IssueAnswer]
            WHERE (
                      ([IssueId] = [issue].[Id])
                      AND NOT ([DeleteMark] = 1)
                  )
        ) AS [Total],
        [issue].[Id] AS [IssueId],
        (
            SELECT TOP 1
                   [AccessLevel]
            FROM [IssueAnswer]
            WHERE (
                      ([IssueId] = [issue].[Id])
                      AND NOT ([DeleteMark] = 1)
                  )
            ORDER BY [Id] DESC
        ) AS [AccessLevel]
    FROM [Issue] issue
        INNER JOIN [AuditIssueLog] log
            ON (
                   (
                       ([issue].[Id] = [log].[IssueId])
                       AND ([log].[IsLast] = 1)
                   )
                   AND ([log].[AuditStatus] = @AuditStatus0)
               )
        INNER JOIN [ForwardIssue] forward
            ON ([issue].[Id] = [forward].[IssueId])
        INNER JOIN [SUB_ACCOUNT_INFO] exp
            ON ([forward].[ReplyUserId] = [exp].[ID])
        INNER JOIN [SUB_ACCOUNT_INFO] account
            ON ([issue].[FromUserId] = [account].[ID])
    WHERE NOT ([issue].[DeleteMark] = 1)
          AND ([exp].[SE_NAME] LIKE '%' + @MethodConst1 + '%')
) t;

SQL语句中定义2个@MethodConst1导致报错了

热忱回答3