首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Microsoft Dynamics 2016

Microsoft Dynamics 2016
EN

Stack Overflow用户
提问于 2016-04-20 06:48:55
回答 1查看 270关注 0票数 0

我试图编写一个fetch来从设施/设备实体中检索BusinessUnitID和设备ID,我已经用c#代码编写了这个获取xml,但是它在行(粗体行)中抛出了一个空引用异常/System.NullReferenceException--我在设施/设备实体中没有任何空值。这是我的代码:

代码语言:javascript
复制
  private static OrganizationService _orgService;
  string fetchBU = @"<fetch version='1.0' output-format='xml-platform' mapping='logical' distinct='false'>
    <entity name='equipment'>
        <attribute name='name' />
        <attribute name='equipmentid' />
        <order attribute='name' descending='false' />
      <filter type='and'>
         <condition attribute='businessunitid' operator='eq-businessid' />
      </filter>
    </entity>
   </fetch>";

EntityCollection ec = _orgService.RetrieveMultiple(new FetchExpression(fetchBU));
if (ec.Entities.Count > 0)
{
   Guid BusinessUnitId = (Guid)ec[0].Attributes["businessunitid"];
}

有人能给我建议一下吗?提前感谢!

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2016-04-20 06:54:41

您还需要在属性中添加businessunitid,而不仅仅是在以下条件下:

代码语言:javascript
复制
string fetchBU = @"<fetch version='1.0' output-format='xml-platform' mapping='logical' distinct='false'>
    <entity name='equipment'>
        <attribute name='name' />
        <attribute name='equipmentid' />
        <attribute name='businessunitid' />
        <order attribute='name' descending='false' />
      <filter type='and'>
         <condition attribute='businessunitid' operator='eq-businessid' />
      </filter>
    </entity>
   </fetch>";
票数 4
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/36735886

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档