因此,我已经安装了automapper软件包和injection软件包,但是我仍然对如何使用它感到困惑。我看到的所有示例都是一个简单的查询。但是,如果我做这样的事情怎么办:
class SomeRepository {
private readonly IMapper _mapper;
private DatabaseContext _context;
public SomeRepository(IMapper mapper, DatabaseContext context) {
...
_mapper.Map(typeof(Worker), typeof(WorkerDto));
}
public IQueryable<SomeNewDto> GetSomething() {
return from s in _context.Space.AsNoTracking()
join w in _context.Worker.AsNoTracking() on s.wwid = w.id
select new SomeNewDto {
Barcode = s.Entry_Bar_Code,
Who = w
};
}
}
如果Who
的类型为WorkerDto
,我该实际放什么,以便进行映射?