【问题标题】:If statement to get different attributes - fetchXML获取不同属性的 if 语句 - fetchXML
【发布时间】:2018-07-04 09:23:20
【问题描述】:

以 SQL 为例,是否可以在 FetchXML 中使用“if select”语句来根据条件获取不同的属性?

例如,如果 @value=1 ,获取属性“a”和“b”,否则,获取属性“c”和“d”。

我是新手。

【问题讨论】:

  • 您是在 SSRS 报告中使用 fetchxml 还是在 js/C# 编码中使用?你能写出你要找的 fetchxml 的 sql 等价物吗?
  • 两者都不是。我在另一个不太著名的软件中使用它。相当于:如果@value=1 从{source} 中选择column_a,column_b,否则从{source} 中选择column_c,column_d。 -- @value是我在软件中可以访问和声明的变量,来源是sql版本中的lookuptable,在Dynamics中变成了实体。每列对应于 Dynamics 中的一个属性。
  • 请编辑问题并添加详细信息,在 cmets 中很难阅读..

标签: dynamics-crm fetchxml


【解决方案1】:

无论是 js/C# 中的 SQL 或 fetchXML 或任何其他技术/软件,实现此要求的唯一方法是 - 动态查询技术。以我们想要的方式在字符串中编写查询并在运行时执行字符串查询。

例如:

string query =  @"
   <fetch mapping='logical'>
     <entity name='contact'>";

if (value == 1)
{
        query+= "<attribute name='title'/> 
                 <attribute name='fullname'/>";
}
else
{
        query+= "<attribute name='firstname'/> 
                 <attribute name='lastname'/>";
}

     query+= "</entity> 
            </fetch>"; 

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2013-06-01
    • 2010-12-09
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2022-11-12
    • 2011-01-27
    相关资源
    最近更新 更多