abp中linq的应用
private IQueryable<MembershipEntity> SelectOrScrrenMember(GetMemberInput input) { string[] userDefinedFilter = null; if (!input.UserDefinedFilter.IsNullOrWhiteSpace()) { userDefinedFilter = input.UserDefinedFilter.Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries);//不保留空元素 } var query = from m in _memberRepository.GetAll() join s in _VipcardRepository.GetAll() on m.Id equals s.MEMBER_CODE join g in _VipcardgradeRepository.GetAll() on s.VIP_CARD_GRADE equals g.CARDGRADECODE select new MembershipEntity { Id = m.Id, ENGLISH_NAME = m.ENGLISH_NAME, CHINESE_NAME = m.CHINESE_NAME, E_MAIL = m.E_MAIL, PHONE_NO_MOBILE = m.PHONE_NO_MOBILE, PHONE_NO_HOME = m.PHONE_NO_HOME, PHONE_NO_OFFICE = m.PHONE_NO_OFFICE, ID_NO = m.ID_NO, REMARK = m.REMARK, CARD_NO = s.CARD_NO, VIP_CARD_GROUP = s.VIP_CARD_GROUP, VIP_CARD_GRADE = s.VIP_CARD_GRADE, CARDGRADEDESC = g.CARDGRADEDESC, IS_ARTIST = m.IS_ARTIST, STATUS = m.STATUS, UserDefinedField = m.USER_DEFINED_FIELD }; query = query.WhereIf(!input.ENGLISH_NAME.IsNullOrWhiteSpace(), item => item.ENGLISH_NAME.Contains(input.ENGLISH_NAME)) .WhereIf(!input.MEMBER_CODE.IsNullOrWhiteSpace(), item => item.Id.Contains(input.MEMBER_CODE)) .WhereIf(!input.PHONE_NO_HOME.IsNullOrWhiteSpace(), item => item.PHONE_NO_HOME.Contains(input.PHONE_NO_HOME)) .WhereIf(!input.PHONE_NO_MOBILE.IsNullOrWhiteSpace(), item => item.PHONE_NO_MOBILE.Contains(input.PHONE_NO_MOBILE)); if (userDefinedFilter != null) { foreach (var filter in userDefinedFilter) { query = query.Where(item => item.UserDefinedField.Contains(filter)); } } return query; }