Dynamics CRM SDK自定义字段上的过滤器查询

Dynamics CRM SDK自定义字段上的过滤器查询

问题描述:

我试图从销售订单实体中将项目拖入我的WPF应用程序(C#) 我在crm中创建了一个名为new_xero并已发布的自定义字段。这是一个双选项字段。我有4个订单,2个没有为这个领域设置任何东西,其中一个选择了“否”,另一个选择了“是”。Dynamics CRM SDK自定义字段上的过滤器查询

我有以下代码:

QueryExpression qeLocations = new QueryExpression("salesorder"); 

     string[] cols = { "salesorderid", "name" }; 
     qeLocations.ColumnSet = new ColumnSet(cols); 


     var locations = this.OrgService.RetrieveMultiple(qeLocations); 

     listBox1.ItemsSource = (from location in locations.Entities 
           where location.GetAttributeValue<string>("new_xero") == "false" 
           //where (bool)location["new_xero"] == false 
            select new 
            { 
             Name = location["name"], 
             LocationID = location["salesorderid"] 
            }).Take(5); 

似乎一切我尝试做行where location.GetAttributeValue<string>("new_xero") == "false"我无法筛选,只有那些在选项设置为“无” 我曾尝试对0进行int过滤,针对'false','False','No','no'的字符串,但似乎无法找到正确的解决方案。

干杯

+0

不应locations.Entitles是locations.BusinessEntities?还检查什么location.GetAttributeValue ( “new_xero”)actualy返回,你可能会发现它是dataType CrmBoolean,我已经看到发生了几次,虽然我通常避免混合var与CRMs服务和使用静态类型 – Stuart 2012-03-08 17:20:03

+0

你还记得在visual studio中刷新webservice referencec获得newley公布的属性? – Stuart 2012-03-08 17:20:51

+0

Hi Stuart,谢谢你的回复。我添加了下面这行'label1.Content = resp.Entity [“new_xero”]。GetType();''将'system.boolean'输出到标签。 BusinessEntities和CrmBoolean在'Microsoft.Xrm.Sdk.EntityCollection'中没有定义时抛出错误,并且没有找到任何类型或名称空间。 – 2012-03-09 10:47:59

找到答案,我需要领域new_xero添加到COLS阵列。 然后要么where location.GetAttributeValue<bool>("new_xero")where location["new_xero"].ToString() == "False"(尽管反对真假!

非常感谢, 克里斯