ASP.NET Core - Angular 8.21 Hi, i have something weird. I have an EmployeeAppService which query users, it worked in v8.0
public async Task<PagedResultDto<EmployeeListDto>> GetEmployees(GetEmployeesInput input)
{
var query = _userRepository.GetAll()
.Include(u => u.TherapistWorkHours)
.Include(u => u.HomeAddress)
.Include(u => u.PostalAddress)
.WhereIf(
!input.Filter.IsNullOrWhiteSpace(),
u =>
u.Name.Contains(input.Filter) ||
u.Surname.Contains(input.Filter) ||
u.UserName.Contains(input.Filter) ||
u.EmailAddress.Contains(input.Filter)
);
var users = query
.Where(u => u.UserName != "admin")
.OrderByDescending(u => u.HireDate).AsQueryable();
var employeesCount = await query.CountAsync();
var employees = users
.OrderBy(input.Sorting)
.PageBy(input)
.ToListAsync();
var employeeListDtos = ObjectMapper.Map<List<EmployeeListDto>>(employees);
return new PagedResultDto<EmployeeListDto>(
employeesCount,
employeeListDtos
);
}
In the log it says missing map, but i am sure the map is there
When i debug and put a watch on employees is says Status Faulted

If i put the same function in UserAppService it works
What am i missing?
I see that in the userappservice the filtering of the users is moved to a private function
4 Answer(s)
-
0
hi
You need use
awaitvar employees = await users .OrderBy(input.Sorting) .PageBy(input) .ToListAsync();Markdown is supportedCopy & paste or drag & drop images (max 30 MB per image) -
0
Hi, yes await was missing, but now i get the following error in the log
ERROR 2020-03-10 15:17:10,626 [27 ] Mvc.ExceptionHandling.AbpExceptionFilter - The LINQ expression 'DbSet<User> .Where(u => __ef_filter__p_0 || !(((ISoftDelete)u).IsDeleted) && __ef_filter__p_1 || ((IMayHaveTenant)u).TenantId == __ef_filter__CurrentTenantId_2) .Where(u => u.UserName != "admin") .OrderByDescending(u => u.HireDate) .OrderBy(u => u.PreferredFullName)' could not be translated. Either rewrite the query in a form that can be translated, or switch to client evaluation explicitly by inserting a call to either AsEnumerable(), AsAsyncEnumerable(), ToList(), or ToListAsync(). See https://go.microsoft.com/fwlink/?linkid=2101038 for more information.
Markdown is supportedCopy & paste or drag & drop images (max 30 MB per image) -
0
- What is
PreferredFullName? - What is
input.Sorting?
Does it work when you remove
OrderBy(input.Sorting)?Markdown is supportedCopy & paste or drag & drop images (max 30 MB per image) - What is
-
0
When i remove the default sorting 'PreferredFullName' it works Thanks
PreferredFullName is when people get married in the Netherlands they can chose how to use lastname, lastname type is an enum PreferredFullName is not stored in DB
`[NotMapped] public virtual string PreferredLastName { get { _partnerFullLastName = GetLastName(PartnerSurName, PartnerSurNamePrefix); _birthFullLastName = GetLastName(Surname, SurnamePrefix);
switch (PreferredLastNameType) { case LastNameType.PartnerNaam: _preferredFullName = _partnerFullLastName; break; case LastNameType.PartnerGeboorte: _preferredFullName = _partnerFullLastName + " - " + _birthFullLastName; break; case LastNameType.GeboortePartner: _preferredFullName = _birthFullLastName + " - " + _partnerFullLastName; break; default: _preferredFullName = _birthFullLastName; break; } return _preferredFullName; } }` thanksMarkdown is supportedCopy & paste or drag & drop images (max 30 MB per image)