×

Fetch xml ile rapor yaparken, 1-n diğer bir entitye join oluyorsanız datalar çoklanıyor. Bunu nasıl engelleriz?

Fetch xml ile rapor yaparken eğer bir entityden 1-n diğer bir entity e join oluyorsanız datalar çoklanıyor.

Örnek vermek gerekirse sipariş entitysine sipariş ürünlerini joinlerseniz.

Bu nedenle gruplama yapmanız lazım. Aşağıda bir örneği bulabilirsiniz. Eklemeniz gereken kısımları koyu (bold) işaretledik.

<fetch version=”1.0″ output-format=”xml-platform” mapping=”logical” count=”5000″ distinct=”true” aggregate=”true”>

  <entity name=”salesorder”>

    <attribute name=”salesorderid” alias=”salesorderid” groupby=”true” />

    <attribute name=”ownerid” alias=”ownerid”  groupby=”true” />

    <attribute name=”totalamount” alias=”totalamount” groupby=”true” />

    <attribute name=”totallineitemamount” alias=”totallineitemamount” groupby=”true” />

    <attribute name=”discountamount” alias=”discountamount” groupby=”true”/>

    <filter type=”and”>

      <condition attribute=”new_sozlesmebaslangictarihi” operator=”on-or-after” value=”@baslangictarihi” />

      <condition attribute=”new_sozlesmebaslangictarihi” operator=”on-or-before” value=”@bitistarihi” />

      <condition attribute=”statuscode” operator=”in”>

        <value>100003</value>

        <value>864730001</value>

      </condition>

    </filter>

    <link-entity name=”salesorderdetail” from=”salesorderid” to=”salesorderid” link-type=”inner” alias=”bc”>

      <link-entity name=”product” from=”productid” to=”productid” link-type=”inner” alias=”bd”>

        <filter type=”and”>

          <condition attribute=”producttypecode” operator=”eq” value=”6″ />

        </filter>

      </link-entity>

    </link-entity>

  </entity>

</fetch>

Yorum gönder