Windowsサービス内でCrmOrganizationServiceContext
のRetrieveMultiple
オペレーションに対してFetchExpression
を使用して、キューからアイテムをフェッチして処理しています。FetchExpressionの結果がキャッシュされているように見えますが、どうすればこの問題を防ぐことができますか?
初めて実行すると、正しく処理されるアイテムが取得されます。同一の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を取得
<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>
をキャッシュされています私の場合は、サービスを変更して、毎回実行するように投票するたびに(10分ごとのような)、私はコンテキストを再インスタンス化し、関連するクラスを新しく始めました。それはオプションですか? – Chris
完全性のために、あなたの 'FetchXml'を投稿できますか? –
@Chris - 私は、毎回インスタンスを作成するために血まみれの年齢がかかるので、好きではありません:( –