0

我想制作其中一列包含值的查询表达式,或者根据条件它将为空或空。示例 - 联系实体

名字 | 姓氏 | 地址1

名称1 | 姓氏1 |
名称2 | 姓氏2 | 地址

名称3 | 姓氏3 | 地址2

现在我想将那些空白列替换为'NA'在sql中我们可以这样编写查询 -

select isnull(address1,'NA') as address from contact

我想在查询表达式中写相同的查询

4

1 回答 1

0

无法获取 fetchxml 来替换服务器端的值。但是为什么不在获取属性值后更改它们呢?你最终会得到相同的结果

const string defaultValue = "NA";
var result = service.RetrieveMultiple(queryExpression);

foreach (var entity in result.Entities)
 {
      if (!entity.Attributes.ContainsKey("address1"))
      {
         entity.Attributes.Add(new KeyValuePair<string, object>("address1", null));
      }
      entity["address1"] = entity["address1"] ?? defaultValue;
  }
于 2016-07-22T15:23:26.253 回答