将ColdFusion查询转换为C#查询表达式

时间:2019-12-10 18:22:08

标签: c# sql asp.net-core coldfusion query-expressions

我正在将旧的Cold Fusion应用程序转换为ASP.NET Core。该应用程序非常耗费数据,并且Cold Fusion代码利用嵌入式SQL查询。我需要将几个Cold Fusion查询转换为.NET查询表达式。例如,以下是典型的Cold Fusion查询:

SELECT
  s2.CriteriaID, s2.Response, s2.NA, s2.Status, s2.resubStatus, s2.staffDetermination, s2.resubStaffDetermination,
  c.CriteriaDesc<cfif getAgency.agencyType NEQ "N">Short</cfif> criteriaDesc, ' ' long_desc
FROM tblASLStep2 s2 
  left outer join tblTableOfContentCriteria c on c.CriteriaNo = s2.criteriaID and c.meetingID = s2.meetingDate
where
  s2.AgencyID = #session.AgencyID#
  and s2.MeetingDate=#session.MeetingDate#
  and (
    (s2.response is not null and ltrim(cast(s2.response as nvarchar)) <> '')
    or exists (
      SELECT 1
      FROM tblASLStep2_narratives n
      WHERE
        n.AgencyID = '#session.AgencyID#'
        and n.CriteriaID = s2.criteriaID
        and n.MeetingDate = #session.MeetingDate#
        and n.narrativeType = 'R'
        and n.response is not null
    )
  )
<cfif session.agencyType neq "F">
  order by replace(replace(s2.CriteriaID, 'ix', 'viiii'), 'Agency Narrative', 1)
<cfelse>
  and s2.criteriaID not like 'SEC5%'
  union all
</cfif> 

我可以达到'from'和SELECT的程度,但是LEFT OUTER JOIN和条件语句部分使我陷入循环。假设表和所有其他变量都存在,将其转换为.NET查询表达式的最佳方法是什么?

1 个答案:

答案 0 :(得分:0)

如果您可以运行旧版系统,启动SQL Server分析器并从分析器运行应用程序,则可以捕获正在发送到数据库的查询。