Windows 서비스 내의 CrmOrganizationServiceContext
에서 RetrieveMultiple
조작에 대한 FetchExpression
을 사용하여 큐에서 항목을 페치하고 처리합니다.FetchExpression 결과가 캐시 된 것처럼 보입니다. 어떻게 방지합니까?
처음 실행하면 올바르게 처리 할 항목을 가져옵니다. 같은 CrmOrganizationServiceContext
인스턴스를 사용하는 후속 호출에서는 오류가 발생하지 않고 항상 0 개의 엔터티를 검색합니다. 새로운 엔티티를 추가하고 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>
나는 비슷한 것을했고 thoug와 같은 종류의 문제를 가졌습니다. h 내 경우에는 서비스가 바뀔 때마다 (매 10 분마다) 실행을 시작할 때마다 컨텍스트와 관련 클래스를 다시 인스턴스화하여 새로운 시작을 얻을 수 있도록 옵션을 변경 했습니까? – Chris
완벽을 기하기 위해'FetchXml'을 게시 할 수 있습니까? –
@Chris - 매번 인스턴스를 만들기 위해 피 묻은 나이가 들기 때문에 선호하지 않습니다. ( –