How to implement the "Where" clause as "in" and "not in" in c# Linq?

Asked

Viewed 26 times

1

I have the following querys:

Select * from Processos where idProcesso in (1,2,3,4,5); 
Select * from Processos where idProcesso not in (1,2,3,4,5);

Where idProcess is a column with data type int.

I also have the following code c# as Linq:

public ICollection<Processo> ObterProcessos(List<int> lista)
        {  

            return context.Processos
                .Where(x => lista.Contains(x.Id))
                .OrderBy(x => x.Id)
                .ToList();
        }
  • I don’t really know if the question is clear to infer that this is the answer, but if it’s not clear it would be closed anyway until it stays.

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.