QueryExpression Query = new QueryExpression { EntityName = "incident", ColumnSet = new ColumnSet(true) };
LinkEntity CustomerEntity = new LinkEntity
{
LinkFromEntityName = "incident",
LinkToEntityName = "account",
LinkFromAttributeName = "customerid",
LinkToAttributeName = "accountid",
EntityAlias = "Customer",
Columns = new ColumnSet("den_firstname", "den_lastname")
};
LinkEntity SubSubTypeEntity = new LinkEntity
{
LinkFromEntityName = "incident",
LinkToEntityName = "den_subsubtype",
LinkFromAttributeName = "den_subsubtypeid",
LinkToAttributeName = "den_subsubtypeid",
JoinOperator = JoinOperator.Inner,
EntityAlias = "SubSubType",
Columns = new ColumnSet("den_resolvedby")
};
Query.ColumnSet = new ColumnSet(true);
Query.LinkEntities.Add(CustomerEntity);
Query.LinkEntities.Add(SubSubTypeEntity);
if (SRStatus > 0)
Query.Criteria.AddCondition("statuscode", ConditionOperator.Equal, SRStatus);
if (ResolutionType > 0)
Query.Criteria.AddCondition("den_roltype", ConditionOperator.Equal, ResolutionType);
CustomerEntity.LinkCriteria.AddCondition("den_lcouserid", ConditionOperator.Equal, lconameId);
FilterExpression childFilter = Query.Criteria.AddFilter(LogicalOperator.Or);
FilterExpression custFilter = CustomerEntity.LinkCriteria.AddFilter(LogicalOperator.Or);
if (!string.IsNullOrEmpty(SearchText))
{
childFilter.AddCondition("den_userid", ConditionOperator.Equal, SearchText);
childFilter.AddCondition("ticketnumber", ConditionOperator.Like, "%" + SearchText + "%");
childFilter.AddCondition("title", ConditionOperator.Equal, SearchText);
//下面的代码正在产生问题,如果我删除它,它会起作用并且我得到结果。但我需要添加两个过滤器
custFilter.AddCondition("name", ConditionOperator.Equal, SearchText);
custFilter.AddCondition("den_firstname", ConditionOperator.Equal, SearchText);
//custFilter.AddCondition("den_lastname", ConditionOperator.Equal, SearchText);
custFilter.AddCondition("emailaddress1", ConditionOperator.Equal, SearchText);
custFilter.AddCondition("telephone1", ConditionOperator.Equal, SearchText);
}
如果我使用 custFilter 或 childFilter 删除所有条件,我会得到结果,但是当我同时保留这两个条件时,它会返回任何结果(无错误)。