2

キューからアイテムをフェッチして処理するために、Windowsサービス内の操作FetchExpressionに対してを使用しています。RetrieveMultipleCrmOrganizationServiceContext

これを初めて実行すると、正しく処理されるアイテムがフェッチされます。同じインスタンスを使用する後続の呼び出しCrmOrganizationServiceContextでは、エラーがスローされることなく、常にゼロのエンティティが取得されます。新しいエンティティを追加し、FetchXmlを使用してフェッチする必要がある既存のエンティティを再アクティブ化しましたが、それらは取得されません。

サービスを再起動するとすぐに、の新しいインスタンスが作成され、CrmOrganizationServiceContext新しいアイテムがフェッチされます。

私はここで何が間違っているのですか?

   public CrmConnector(string connectionString)
   {
        Context = new CrmOrganizationServiceContext(CrmConnection.Parse(connectionString));
   }

   public void FetchStuff()
   {
        string fetchXml = "...";
        FetchExpression fetchExpression = new FetchExpression(fetchXml);
        EntityCollection entityCollection = Context.RetrieveMultiple(fetchExpression);
        // entityCollection.Entities is always empty following first run
    }

    private CrmOrganizationServiceContext Context { get; set; }

要求に応じてXmlをフェッチします。唯一のカスタマイズは、返されるアイテムの数を制限するcount属性です(これはキュープロセッサであるため)

  <fetch version="1.0" output-format="xml-platform" mapping="logical" distinct="false" count="10">
    <entity name="xxx1">
      <attribute name="xxx_name" />
      <attribute name="createdon" />
      <attribute name="xxx_1" />
      <attribute name="xxx_2" />
      <attribute name="xxx_3" />
      <attribute name="xxx_4" />
      <attribute name="statecode" />
      <order attribute="createdon" descending="false" />
      <filter type="and">
        <condition attribute="xxx_exported" value="0" operator="eq"/>
      </filter>
    </entity>
  </fetch>
4

1 に答える 1

3

キャッシングを行っているのはそれですCrmOrganizationServiceContext-以下がうまく機能し、RetrieveMultipleの結果がキャッシュされなくなったことがわかりました:)

Context = new CrmOrganizationServiceContext(CrmConnection.Parse(connectionString));
Context.TryAccessCache(cache => cache.Mode = OrganizationServiceCacheMode.Disabled);
于 2011-12-12T10:43:02.093 に答える