gee*_*ent 1 crm query-expressions dynamics-crm-2011
我有一个实体LeaveType有两个属性,1.类型,2.可用天数,其中Type是一个选项集,Available days是一个文本字段.我想获取所有这些LeaveType记录,其中Type ='Annual'在选项集中选择.我无法找到如何为选项设置值添加过滤器查询表达式.以下是我的进度方法:
public Entity Getleavetype(Guid LeaveDetailsId, IOrganizationService _orgService, CodeActivityContext Acontext)
{
QueryExpression GetLeavedetails = new QueryExpression();
GetLeavedetails.EntityName = "sgfdhr_leavetype";
GetLeavedetails.ColumnSet = new ColumnSet("new_type");
GetLeavedetails.ColumnSet = new ColumnSet("new_availabledays");
GetLeavedetails.Criteria.AddCondition("new_type", ConditionOperator.Equal, "Annual" ); //Is this correct????
GetLeavedetails.Criteria.AddCondition("new_employeeleavecalculation", ConditionOperator.Equal, LeaveDetailsId); //ignore this
//((OptionSetValue)LeaveDetailsId["new_leavetype"]).Value
EntityCollection LeaveDetails = _orgService.RetrieveMultiple(GetLeavedetails);
return LeaveDetails[0];
}
Run Code Online (Sandbox Code Playgroud)
在您的情况下,您需要设置选项集的整数值,而不是标签.
假设该Annual
值是例如2,代码将是:
GetLeavedetails.Criteria.AddCondition("new_type", ConditionOperator.Equal, 2);
Run Code Online (Sandbox Code Playgroud)