I am trying to query sql , using EntityFramework :
select * from pedidos
where pedidoID not in (select pedidoID from agendamentos);
I did some research and found that the EntityFramework method that replaces the not in
of sql is Contains()
.
Then I put the following code:
var pedidos = Db.Pedidos.Where(x =>
Db.Pedidos.Where(y => y.PedidoId == x.Agendamentos.Select(z=>z.PedidoId).
FirstOrDefault()).Select(y => y.PedidoId).ToList().
Contains(
Db.Pedidos.Where(z=>z.PedidoId == x.PedidoId).
Select(y => y.PedidoId).FirstOrDefault())
).
ToPagedList(1, RecordsPerPage);
With the Contains method I get the following error:
I believe that being a requested timeout , the sql search is taking a long time to run, so I tried to put conditions on the listing size, giving the same error.
So the function works perfectly:
If you can help me with this problem, I'll be grateful!