キューからアイテムをフェッチして処理するために、Windowsサービス内の操作FetchExpression
に対してを使用しています。RetrieveMultiple
CrmOrganizationServiceContext
これを初めて実行すると、正しく処理されるアイテムがフェッチされます。同じインスタンスを使用する後続の呼び出し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>