【发布时间】:2014-08-09 15:37:26
【问题描述】:
我有一些性能很慢的 SQL 报告,所以我们将它们全部转换为 FetchXML,但所有 SQL 报告的条件都是可选的,如下所示:
SELECT
...
FROM ...
WHERE (@operator = 'All' OR Operator = @operator)
AND (@new_gen_comp_name = 'All' OR new_gen_comp_name = @new_gen_comp_name)
...
在参数值中,有一个值All,如果用户选择该值,则该条件将被忽略,因此它将从该字段中获取所有值。
现在我想在 FetchXML 中执行此操作,我尝试在它们之间放置两个带有过滤器 or 的条件,一个用于值,另一个用于包含如下所示的空值:
<fetch version="1.0" output-format="xml-platform" mapping="logical" distinct="true">
<entity name="incident">
...
...
<filter type="and">
<filter type="and">
<condition attribute="createdon" operator="on-or-after" value="@StartDate" />
<condition attribute="createdon" operator="on-or-before" value="@EndDate" />
</filter>
<filter type="or">
<condition attribute="new_gen_comp_type" operator="in" value="@new_gen_comp_type" />
<condition attribute="new_gen_comp_type" operator="null" />
</filter>
</filter>
...
...
</entity>
</fetch>
这只有在用户选择参数@new_gen_comp_type 的所有值时才能正常工作,但问题是如果用户只选择特定值,它也会包含空值,这是错误的。
那么,如果用户选择select all 作为 SQL 中的参数值,是否有任何方法可以使这些条件成为可选?
【问题讨论】:
-
你找到解决这个问题的方法了吗?
-
@MoisesCardenas 是的,请参阅下面的答案。
标签: reporting-services dynamics-crm-2011 dynamics-crm dynamics-crm-2013 fetchxml