public virtual async Task <AppPagedResultOutput <SoftLicenseListDto> > GetLicensePageList(long softId, GetPageListInput input) { var query = _softLicenseRepository.GetAll(); var where = FilterExpression.FindByGroup <SoftLicense>(input.Filter); where = where.And(t => t.SoftId == softId); var queryCount = query.Where(where) .GroupJoin(_softUserRepository.GetAll(), softLicense => softLicense.SoftUserId, softUser => softUser.Id, (softLicense, softUser) => new { SoftLicense = softLicense, SoftUser = softUser }); if (FilterExpression.HasValue(input.Filter, "loginName")) { string value = FilterExpression.GetValue(input.Filter, "loginName"); queryCount = queryCount.Where(t => t.SoftUser.FirstOrDefault().LoginName.Contains(value)); } int count = await queryCount.CountAsync(); var queryList = query.Where(where) .GroupJoin(_softUserRepository.GetAll(), softLicense => softLicense.SoftUserId, softUser => softUser.Id, (softLicense, softUser) => new { SoftLicense = softLicense, SoftUser = softUser }); //queryList = queryList.Where(t => t.SoftUser.FirstOrDefault().LoginName.Contains("001")); if (FilterExpression.HasValue(input.Filter, "loginName")) { string value = FilterExpression.GetValue(input.Filter, "loginName"); queryList = queryList.Where(t => t.SoftUser.FirstOrDefault().LoginName.Contains(value)); } queryList = queryList.OrderByDescending(t => t.SoftLicense.CreationTime) .PageBy(input); var list = await queryList.Select(t => new SoftLicenseListDto { Id = t.SoftLicense.Id, ApplyTime = t.SoftLicense.ApplyTime, CreationTime = t.SoftLicense.CreationTime, LicenseNo = t.SoftLicense.LicenseNo, LicenseType = t.SoftLicense.LicenseType, Price = t.SoftLicense.Price, Status = t.SoftLicense.Status, UseTime = t.SoftLicense.UseTime, SoftUser_LoginName = t.SoftUser.FirstOrDefault().LoginName }).ToListAsync(); var pageList = list; return(new AppPagedResultOutput <SoftLicenseListDto>(count, pageList, input.CurrentPage, input.PageSize)); }
public virtual async Task <AppPagedResultOutput <SoftUserLoginListDto> > GetLoginPageList(GetPageListInput input) { var query = _softUserLoginRepository.GetAll(); var where = FilterExpression.FindByGroup <SoftUserLogin>(input.Filter); var queryCount = query.Where(where) .GroupJoin(_softUserRepository.GetAll(), left => left.SoftUserId, right => right.Id, (left, right) => new { UserLicense = left, SoftUser = right }) .GroupJoin(_softRepository.GetAll(), left => left.UserLicense.SoftId, right => right.Id, (left, right) => new { SoftUserLicense = left.UserLicense, SoftUser = left.SoftUser, Soft = right }); if (FilterExpression.HasValue(input.Filter, "loginName")) { string value = FilterExpression.GetValue(input.Filter, "loginName"); queryCount = queryCount.Where(t => t.SoftUser.FirstOrDefault().LoginName.Contains(value)); } if (FilterExpression.HasValue(input.Filter, "softName")) { string value = FilterExpression.GetValue(input.Filter, "softName"); queryCount = queryCount.Where(t => t.Soft.FirstOrDefault().Name.Contains(value)); } int count = await queryCount.CountAsync(); var queryList = query.Where(where) .GroupJoin(_softUserRepository.GetAll(), left => left.SoftUserId, right => right.Id, (left, right) => new { SoftUserLogin = left, SoftUser = right }) .GroupJoin(_softRepository.GetAll(), left => left.SoftUserLogin.SoftId, right => right.Id, (left, right) => new { SoftUserLogin = left.SoftUserLogin, SoftUser = left.SoftUser, Soft = right }); if (FilterExpression.HasValue(input.Filter, "loginName")) { string value = FilterExpression.GetValue(input.Filter, "loginName"); queryList = queryList.Where(t => t.SoftUser.FirstOrDefault().LoginName.Contains(value)); } if (FilterExpression.HasValue(input.Filter, "softName")) { string value = FilterExpression.GetValue(input.Filter, "softName"); queryList = queryList.Where(t => t.Soft.FirstOrDefault().Name.Contains(value)); } queryList = queryList.OrderByDescending(t => t.SoftUserLogin.CreationTime) .PageBy(input); var list = await queryList.Select(t => new SoftUserLoginListDto { Id = t.SoftUserLogin.Id, Mcode = t.SoftUserLogin.Mcode, Ip = t.SoftUserLogin.Ip, CreationTime = t.SoftUserLogin.CreationTime, SoftName = t.Soft.FirstOrDefault().Name, LoginName = t.SoftUser.FirstOrDefault().LoginName }).ToListAsync(); var pageList = list; return(new AppPagedResultOutput <SoftUserLoginListDto>(count, pageList, input.CurrentPage, input.PageSize)); }