• linq一堆多再对多


    查出来0条

            public async Task<PagedResultDto<ProFileListDto>> GetAll(ProFileListInput input)
            {
                var query = from a in _proFileRepository.GetAll()
                            join b in _filingAgreementRepository.GetAll() on a.Id equals b.ProFileId into list
                            from c in list.DefaultIfEmpty()
                            join d in _filesRepository.GetAll() on c.PdfFileUrlId equals d.Id
                            where (string.IsNullOrEmpty(input.Name) || a.Name == input.Name) &&
                                  (!input.GraduationTime.HasValue || a.GraduationTime.Year == input.GraduationTime.Value) &&
                                  (!input.Birthday.HasValue || a.Birthday.Value.Year == input.Birthday.Value.Year
                                                                 && a.Birthday.Value.Month == input.Birthday.Value.Month) &&
                                  (string.IsNullOrEmpty(input.IdCard) || a.IdCard == input.IdCard) &&
                                  (!input.ProFileState.HasValue || a.ProFileState == input.ProFileState) &&
                                  (!input.ProFileType.HasValue || a.ProFileType == input.ProFileType) &&
                                  (string.IsNullOrEmpty(input.GraduatedSchool) || a.GraduatedSchool == input.GraduatedSchool)
                            select new { a, url=d==null?"":d.FliePath };
    
    
    
                var count = await query.CountAsync();
                var items = await query.OrderBy(input.Sorting).PageBy(input).ToListAsync();
    
                return new PagedResultDto<ProFileListDto>(
                    count,
                    items.Select(item =>
                    {
                        var dto = ObjectMapper.Map<ProFileListDto>(item.a);
                        //if (item.c != null)
                        //{
                        //    dto.FilingAgreementFileUrl = ( _filesRepository.Get(item.c.PdfFileUrlId)).FliePath;
                        //}
                        dto.FilingAgreementFileUrl = item.url;
                        return dto;
                    }).ToList());
            }

    正常

           public async Task<PagedResultDto<ProFileListDto>> GetAll(ProFileListInput input)
            {
                var query = from a in _proFileRepository.GetAll()
                            join b in _filingAgreementRepository.GetAll() on a.Id equals b.ProFileId into list
                            from c in list.DefaultIfEmpty()
                            join d in _filesRepository.GetAll() on c.PdfFileUrlId equals d.Id into list2
                            from e in list2.DefaultIfEmpty()
                            where (string.IsNullOrEmpty(input.Name) || a.Name == input.Name) &&
                                  (!input.GraduationTime.HasValue || a.GraduationTime.Year == input.GraduationTime.Value) &&
                                  (!input.Birthday.HasValue || a.Birthday.Value.Year == input.Birthday.Value.Year
                                                                 && a.Birthday.Value.Month == input.Birthday.Value.Month) &&
                                  (string.IsNullOrEmpty(input.IdCard) || a.IdCard == input.IdCard) &&
                                  (!input.ProFileState.HasValue || a.ProFileState == input.ProFileState) &&
                                  (!input.ProFileType.HasValue || a.ProFileType == input.ProFileType) &&
                                  (string.IsNullOrEmpty(input.GraduatedSchool) || a.GraduatedSchool == input.GraduatedSchool)
                            select new { a, url = e == null ? "" : e.FliePath };
                
    
    
                var count = await query.CountAsync();
                var items = await query.OrderBy(input.Sorting).PageBy(input).ToListAsync();
    
                return new PagedResultDto<ProFileListDto>(
                    count,
                    items.Select(item =>
                    {
                        var dto = ObjectMapper.Map<ProFileListDto>(item.a);
                        //if (item.c != null)
                        //{
                        //    dto.FilingAgreementFileUrl = (_filesRepository.Get(item.c.PdfFileUrlId)).FliePath;
                        //}
                        dto.FilingAgreementFileUrl = item.url;
                        return dto;
                    }).ToList());
            }
  • 相关阅读:
    Linux OTG当串口、网口、U盘
    Linux 双网卡双网段通信
    Buildroot Savedefconfig
    OTG作为大容量设备
    EntityFramework Core问题处理集锦(一)
    EntityFramework Core数据查询
    ASP.NET Core MVC请求超时设置解决方案
    EntityFramework Core迁移时出现数据库已存在对象问题解决方案
    EntityFramework Core映射关系详解
    探讨SQL Server并发处理存在就更新七种解决方案
  • 原文地址:https://www.cnblogs.com/wangyinlon/p/13187313.html
Copyright © 2020-2023  润新知