一、
public async Task<ListResultDto<ArchitectureDto>> GetArchitecture() { var architecture = _architectureRepository.GetAll(); var list= await architecture.ToListAsync(); return new ListResultDto<ArchitectureDto>( list.Select(item => { var architectureDto = ObjectMapper.Map<ArchitectureDto>(item); return architectureDto; }).ToList()); }
二、
public async Task<PagedResultDto<ArcClassroomListDto>> GetArchitectureClassroom(GetAllArchitecturesInput input) { var query = (from c in _classroomRepository.GetAll().Include("Architecture").Include("Nature").Include("Architecture.Parent.Parent").Include("Architecture.Children") join a in _architectureRepository.GetAll() on c.ArchitectureId equals a.Id join n in _natureRepository.GetAll() on c.NatureId equals n.Id where a.Id == input.Id||a.ParentId== input.Id || a.Parent.ParentId == input.Id || a.Parent.Parent.ParentId == input.Id select c); var totalCount = await query.CountAsync(); var items = await query.OrderBy(input.Sorting?? "id asc").PageBy(input).ToListAsync(); return new PagedResultDto<ArcClassroomListDto>( totalCount, items.Select(item => { var organizationUnitUserDto = new ArcClassroomListDto(); organizationUnitUserDto.CampusName = item.Architecture.Parent.Parent.Name ; organizationUnitUserDto.BuildingName = item.Architecture.Parent.Name; organizationUnitUserDto.FloorName = item.Architecture.Name ; organizationUnitUserDto.Name = item.Name; organizationUnitUserDto.ClassroomNatureName = item.Nature.Name; organizationUnitUserDto.Id = item.Id; organizationUnitUserDto.Maximum = item.Maximum; return organizationUnitUserDto; }).ToList()); }