I'm needing and am having trouble getting this sql with subquery and doing the same thing in c # entity.
SELECT Id,Nome,
(SELECT Count(Id) FROM Pedidos
WHERE Pedidos.ColaboradorId = Colaborador.Id) AS NumeroPedidos
FROM Colaborador
ORDER BY Nome DESC;
I need to turn this SQL up.
var retornoColaborador = db.Colaboradores.Where(a => a.Id == db.Pedidos.Where(b => b.ColaboradorId == a.Id).Count());
I tried to do something like this but it did not work.