[英]Dynamics CRM SDK filter query on custom field
我正在尝试将salesorder实体中的项目拖入我的WPF应用程序(C#)我在crm中创建了一个名为new_xero的自定义字段并已发布。 这是一个双选项字段。 我有4个订单,2个没有为此字段设置任何内容,一个选择“否”,一个选择“是”。
我有以下代码:
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"
这一行做的一切我只能过滤到那些选项设置为'no'的地方我尝试过滤过滤反对0,字符串反对'false','False','No','no'但似乎无法找到正确的解决方案。
干杯
找到答案,我需要将字段new_xero添加到cols数组中。 然后where location.GetAttributeValue<bool>("new_xero")
或where location["new_xero"].ToString() == "False"
(虽然反对真假!
非常感谢,克里斯
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.