将 SQL 转换为 FetchXML 错误?

Convert SQL to FetchXML error?

尝试快速将以下内容转换为 Fetch XML,但出现以下错误。

Error: Error occurred when parsing the SQL script: Unsupported statement type: DECLARE

DECLARE 
    @OrganisationId uniqueidentifier

SELECT
    cil.mm_topprioritystatus,
    cil.mm_achievedcatalogproductName,
    cil.mm_achievedcatalogproductstatus,
    ci.mm_key
FROM
    mm_catalogitemtorganisationlinker cil
INNER JOIN
    mm_catalogitem ci on 
        ci.mm_catalogitemId = cil.mm_catalogitem    
where 
    mm_organisation = @OrganisationId
    and ci.mm_key in (
        'LEVEL1',
        'LEVEL2',
        'LEVEL3',
        'LEVEL4'
    )

请告知上面的 fetchXML 版本。

这是一种可能的解决方案:

<fetch>
  <entity name='mm_catalogitemtorganisationlinker' >
    <attribute name='mm_topprioritystatus' />
    <attribute name='mm_achievedcatalogproductName' />
    <attribute name='mm_achievedcatalogproductstatus' />
    <filter>
      <condition attribute='mm_organisation' operator='eq' value='{organizationid}' />
    </filter>
    <link-entity name='mm_catalogitem' from='mm_catalogitemid' to='mm_catalogitem' link-type='inner' alias='ci' >
      <attribute name='mm_key' />
      <filter>
        <condition attribute='mm_key' operator='in' >
          <value>LEVEL1</value>
          <value>LEVEL2</value>
          <value>LEVEL3</value>
          <value>LEVEL4</value>
        </condition>
      </filter>
    </link-entity>
  </entity>
</fetch>

当然要用代码替换{organizationid}占位符。