【发布时间】:2012-08-06 19:57:34
【问题描述】:
我正在尝试使用 Automapper 将 IQueryable
public virtual IQueryable<TDto> Get()
{
IQueryable<TEntity> EntObjs;
EntObjs = GenericService.Get();
var Dtos = EntObjs.Project().To<TDto>();
return Dtos;
}
只要 Tentity 类型中没有任何集合,它就可以正常工作。我在http://www.devtrends.co.uk/blog/stop-using-automapper-in-your-data-access-code 找到了解决问题的方法。我知道我可以使用以下函数使用 Automapper 映射集合,但我需要它在 linq 中,这样我就不会破坏 Iquerable 链。
Mapper.Map<TSource, TDestination>(Source,Destincation);
【问题讨论】:
标签: asp.net entity-framework automapper asp.net-web-api dto