C# AutoMapper Map返回List<Dto>值为空,对应的Entity有数据

最近在研究AutoMapper,到Mapper.Map<List<MenuEntity>, List<MenuDto>>(list);总是返回结构数是0,而实际上list是有数据的

google了好久发现用ProjectTo可以

需添加 using AutoMapper.QueryableExtensions;

但是当我再次用先前的方法:return Mapper.Map<List<MenuEntity>, List<MenuDto>>(list); 时,又有返回值了

不知道为什么,反正目前看来,这两种方法都是可以的

参考地址:

https://codewithstyle.info/solving-entity-framework-performance-issues-automapper/

http://docs.automapper.org/en/stable/Queryable-Extensions.html?highlight=List 

原文地址:https://www.cnblogs.com/pashanhu/p/9651122.html