我正在尝试使用 Automapper 投影我的 EF Core 查询以允许在我的应用程序中使用第 3 层,但我在允许 HotChocolate 请求我的 DTO 上的字段并告诉 Automapper 将这些字段包含在投影过程中时遇到了一些麻烦。
提前几个重要的点:
- 当两个属性都存在时,Automapper 将请求地图上的所有 NavigationProperties
ExplicitExpansion
设置存在时除外- 如果
ExplicitExpansion
在地图上设置,HotChocolate 无法IQueryable
使用[UseProjection]
所以我可以一次性加载所有导航属性,也可以不加载。
如何告诉 ether HotChocolate 映射 my 中的实体IQueryable
,或者如何在查询函数中获取所需的键来告诉 AutoMapper 使用该IQueryable<T>.ProjectTo()
方法扩展哪些属性?