SQL “not in” syntax for Entity Framework 4.1

前端 未结 4 2131
别跟我提以往
别跟我提以往 2020-12-15 04:32

I have a simple issue with Entity Framework syntax for the \"not in\" SQL equivalent. Essentially, I want to convert the following SQL syntax into Entity Framework syntax:<

4条回答
  •  一个人的身影
    2020-12-15 05:01

    This one requires you to think backwards a little bit. Instead of asking if the value is not in some list of ids, you have to ask of some list of id's does not contain the value. Like this

    int[] list = new int[] {1,2,3}
    Result = (from x in dbo.List where list.Contains(x.id) == false select x);
    

提交回复
热议问题