How do you implement the equivalent of SQL IN() using .net

前端 未结 9 1481
春和景丽
春和景丽 2020-12-09 16:24

In .net (c# or vb) expressions, how would you implement SQL\'s handy IN() functionality?

i.e. value in (1, 2, 4, 7)

rather than:

value = 1 or value =

9条回答
  •  隐瞒了意图╮
    2020-12-09 16:31

    Or using System.Linq...

    (VB.NET)

    Enumerable.Contains({1, 2, 4, 7}, value)
    

    or

    {1, 2, 4, 7}.Contains(value)
    

    (C#)

    Enumerable.Contains(new int[]{1, 2, 4, 7}, value);
    

    or

    new int[] {1, 2, 4, 7}.Contains(value);
    

提交回复
热议问题