zoukankan      html  css  js  c++  java
  • 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());
            }
  • 相关阅读:
    "Java:comp/env/"讲解与JNDI
    table的td去边框
    jsp获取所有参数
    spring-mvc设置首页
    jdbc数据库连接方式
    文件上传
    SMBMS
    过滤器和监听器
    解决Maven的JDK版本问题
    MVC
  • 原文地址:https://www.cnblogs.com/wangyinlon/p/13187313.html
Copyright © 2011-2022 走看看