【发布时间】:2021-12-05 20:51:10
【问题描述】:
这里是C#初学者,我只想看到经理与当前用户年龄相同的设施。
由于某种原因,当我使用此代码发布我的网站并尝试查看设施时,我收到一个很长的错误,指出:
***Unable to retrieve facilities from the server. Errors: "error: AutoMapper.AutoMapperMappingException: Error mapping types. Mapping types: WhereListIterator`1 -> IEnumerable`1 System.Linq.Enumerable+WhereListIterator`1[ ***
函数如下:
[HttpGet]
public async Task<IACtionResult> GetFacilities(int page, int pagesize){
var facilities = await _facilityService.GetAllfacilitiesAsync(page, pagesize);
var curr_Age = (int)HttpContext.User.GetAge();
facilities = facilities.Where(facility => facility.Manager.Age == curr_Age);
var model = _mapper.Map<IEnumerable<FacilityViewModel>>(facilities);
return OK(model);
}
当我不按年龄过滤时,我没有问题查看所有设施,所以我不知道导致此问题的原因是什么?
【问题讨论】:
标签: c# .net automapper nullreferenceexception