/// <summary> /// 获取组织通讯录查询条件 /// </summary> /// <param name="context"></param> /// <returns></returns> private System.Linq.Expressions.Expression <Func <User, bool> > GetAddressBookUserPredicate(HttpContext context) { System.Linq.Expressions.Expression <Func <User, bool> > predicate = p => p.Status == 1; bool isSearchKey = false; string orgId = context.Request["orgId"]; predicate = p => (p.Status == 1); #region ------获取查询条件---------- var account = context.Request["Account"]; if (!String.IsNullOrEmpty(account)) { predicate = predicate.And(p => (p.DisplayName.Contains(account) || p.Account.Contains(account))); isSearchKey = true; } var postName = context.Request["PostName"]; if (!String.IsNullOrEmpty(postName)) { //predicate = predicate.And(p => (p.PostName.Contains(postName))); //isSearchKey = true; } var department = context.Request["Department"]; if (!String.IsNullOrEmpty(department)) { predicate = predicate.And(p => (p.OrganizationName.Contains(department))); isSearchKey = true; } var officeName = context.Request["OfficeName"]; if (!String.IsNullOrEmpty(officeName)) { predicate = predicate.And(p => (p.OfficeName.Contains(officeName))); isSearchKey = true; } var address = context.Request["Address"]; if (!String.IsNullOrEmpty(address)) { predicate = predicate.And(p => (p.Address.Contains(address))); isSearchKey = true; } var officePhone = context.Request["OfficePhone"]; if (!String.IsNullOrEmpty(officePhone)) { predicate = predicate.And(p => (p.OfficePhone.Contains(officePhone))); isSearchKey = true; } #endregion if (!isSearchKey) { if (string.IsNullOrEmpty(orgId)) { return(null); } predicate = predicate.And(p => (p.OrganizationID == orgId)); } return(predicate); }