问题
Query:
Select * from pu_Products
where Part_Number in ('031832','027861', '028020', '033378')
and User_Id = 50 and Is_Deleted = 0
The above mentioned query is in SQL and i need the query might be converted into Linq. Is there any option using the "IN" operator in Linq?. can you convert above mentioned query into Linq?
回答1:
dbContext.Products
.Where(p => (new string[] {"031832","027861","028020","033378"})
.Contains(p.Part_Number) && p.Is_Deleted == false);
来源:https://stackoverflow.com/questions/2714681/how-to-use-in-operator-in-linq