具有与automapper的映射,该映射将Orders实体映射到OrdersDto 我会添加一个不在域表(订单)中的计算字段
我不知道是否可行,是否正确询问,但我希望代码会有所帮助
CreateMap<Orders, OrdersDto>()
.ForMember(x => x.Id, conf => conf.MapFrom(i => i.OrderId))
...other fields
var orders = _ordersRepository.GetOrders();//<==Orders Table
var ordersView = (from o in orders
join s in solvency on o.Code equals s.Code
into os
from x in os.DefaultIfEmpty()
let computed = ...
select new
{
fields...
MyComputed = x.computed //<== want to include
})
.ToList();
我希望使用
可以使动作控制器中的查询更具可读性ProjectTo<OrdersDto>()
使用linq将投影移到不寻常的物体上