/// <summary> /// 根据条件查询计划,返回查询的实体列表 /// </summary> /// <param name="mSearchMember">员工查询类对象</param> /// <returns></returns> public async Task <IEnumerable <MemberInfoDto> > GetEntitiesAsync(MemberInfoSearch mSearchMember) { IQueryable <MemberInfoEntity> Items = _GhDbContext.dsMembers.AsNoTracking() as IQueryable <MemberInfoEntity>; if (mSearchMember != null) { if (!string.IsNullOrWhiteSpace(mSearchMember.Id)) { Items = Items.Where(e => e.Id.Trim().Equals(mSearchMember.Id, StringComparison.Ordinal));//对两个字符串进行byte级别的比较,性能好、速度快。 } if (!string.IsNullOrWhiteSpace(mSearchMember.Name)) { Items = Items.Where(e => e.Name.Contains(mSearchMember.Name, StringComparison.Ordinal)); } if (!string.IsNullOrWhiteSpace(mSearchMember.UnitName)) { Items = Items.Where(e => e.UnitName.Contains(mSearchMember.UnitName, StringComparison.Ordinal)); } if (!string.IsNullOrWhiteSpace(mSearchMember.Age)) { if (int.TryParse(mSearchMember.Age, out int Age)) { Items = Items.Where(e => DateTime.Now.Year - e.Birthday.Year > Age); } } if (!string.IsNullOrWhiteSpace(mSearchMember.EducationTop)) { Items = Items.Where(e => e.EducationTop.Contains(mSearchMember.EducationTop, StringComparison.Ordinal)); } if (!string.IsNullOrWhiteSpace(mSearchMember.TechnicalTitle)) { Items = Items.Where(e => e.TechnicalTitle.Contains(mSearchMember.TechnicalTitle, StringComparison.Ordinal)); } if (!string.IsNullOrWhiteSpace(mSearchMember.PoliticalStatus)) { Items = Items.Where(e => e.PoliticalStatus.Contains(mSearchMember.PoliticalStatus, StringComparison.Ordinal)); } List <MemberInfoEntity> RecordEntities = await Items.ToListAsync().ConfigureAwait(false); return(_Imapper.Map <List <MemberInfoDto> >(RecordEntities)); } return(new List <MemberInfoDto>()); }
public async Task <ActionResult <IEnumerable <MemberInfoDto> > > ReadDtos([FromQuery] MemberInfoSearch mSearchMember) { IEnumerable <MemberInfoDto> Dtos = await _MemberRepository.GetEntitiesAsync(mSearchMember).ConfigureAwait(false); return(Ok(Dtos)); }