如何在使用 lt 和 gt 以及使用 ge&le 时获取 fetchxml 以查找所有帐户无法按预期工作



我刚刚开始使用fetchxml和dynamics 365(v9)...

因此,我有一个 dynamics 365 计划服务,需要将其分解为较小的块。但是,在为每个计划构建 fetchxml 查询时,我发现总和没有加起来。

未筛选帐户名称的整个查询为 1158。

但是当使用条件(如下)时,当我将所有结果加起来时,我仍然做空 37 个帐户。

<!-- this query Returns 1158 account objects. -->
<fetch distinct="true">
<entity name="account" >
<attribute name="name" />
<attribute name="accountid" />
<filter type="and" >
<condition attribute="accounttype" operator="in" >
<value>1</value>
<value>2</value>
</condition>
<condition attribute="statuscode" operator="eq" value="1" />
</filter>
<link-entity name="account" from="parentaccountid" to="accountid" link-type="inner" >
<filter type="or" >
<condition attribute="statuscode" operator="eq" value="403310000" />
<condition attribute="statuscode" operator="eq" value="403310007" />
</filter>
</link-entity>
</entity>
</fetch>

我打破了过滤器,只包含以两个字母开头的帐户名称,然后我重复此操作,直到覆盖整个字母表。


<filter type="and" >
<condition attribute="name" operator="gt" value="a" />
<condition attribute="name" operator="lt" value="i" />
</filter>
<filter type="and" >
<condition attribute="name" operator="gt" value="j" />
<condition attribute="name" operator="lt" value="q" />
</filter>
<filter type="and" >
<condition attribute="name" operator="gt" value="r" />
<condition attribute="name" operator="lt" value="z" />
</filter>

然后我发现我还需要添加数字...很公平...

<filter type="and" >
<condition attribute="name" operator="gt" value="0" />
<condition attribute="name" operator="lt" value="9" />
</filter>

所有这些查询加起来就是 1121,仍然短 37

。所以,我想我一定犯了一个错误,应该在上面的过滤器中使用"ge"和"le",我得到了完全相同的结果。

<filter type="and" >
<condition attribute="name" operator="ge" value="s1" />
<condition attribute="name" operator="le" value="s2" />
</filter>

我应该使用哪些其他过滤器来使用此方法检索整个集?

难道不应该使用"不太平等"和"更大平等"工作并包括给我整套的当前信件吗?

编辑1:在圭多的建议之后:

结果现在只比总数少 5 个。 这么近!

<filter type="or" >
<filter type="and" >
<condition attribute="name" operator="ge" value="a" />
<condition attribute="name" operator="le" value="z" />
</filter>
<filter type="and" >
<condition attribute="name" operator="ge" value="0" />
<condition attribute="name" operator="le" value="9" />
</filter>
<!-- adding this extra condition almost finds the entire results 5 short -->
<filter type="and" >
<condition attribute="name" operator="gt" value="a" />
<condition attribute="name" operator="lt" value="z" />
</filter>
<filter type="and" >
<condition attribute="name" operator="ge" value=" " />
<condition attribute="name" operator="le" value="~" />
</filter>
</filter>

编辑 2:已更正。谢谢圭多。这行得通。检索所有帐户。

<filter type="or" > 
<filter type="and" > 
<condition attribute="name" operator="le" value="a" /> 
</filter>
<filter type="and" > 
<condition attribute="name" operator="gt" value="a" /> 
<condition attribute="name" operator="lt" value="z" /> 
</filter> 
<filter type="and" > 
<condition attribute="name" operator="ge" value="z" /> 
</filter> 
</filter>

下一步是使用此方法将结果分解为更小的块......

如果您需要将结果分解为较小的块,我建议您改用分页。 您可以通过在查询的fetch节点上设置属性countpage来添加要检索的页面大小和页面。

<fetch count='5' page='1' distinct='true' >

在结果中,您可以查找属性morerecords以查看是否应继续查询下一页。

相关内容