【发布时间】:2021-05-03 15:45:04
【问题描述】:
我想从查询中返回 DTO,但它不返回任何内容。 我不知道我是否做得对,但 where 条件存在。
public class ServiciosComandasController : ApiController
{
private TPVRestauranteEntities db = new TPVRestauranteEntities();
// GET: api/ServiciosComandas
public async Task<IQueryable<ServicioComandaDTO>> GetAsync()
{
var ServicioComandaDTO = from s in db.Servicios
where s.Mesas.Ocupada == false
select new ServicioComandaDTO()
{
ID = s.ID,
NumeroMesa = s.Mesas.Numero,
FechaModificacion = s.Pedidos.OrderByDescending(p => p.FechaModificacion).FirstOrDefault<Pedidos>().FechaModificacion,
Pendientes = s.Pedidos.Where(p => p.Comidas.Categorias.Encargado == "Cocina").Count()
};
return ServicioComandaDTO;
}
}
【问题讨论】: