LINQ To SQL中如何使用IN

有读者来信问及LINQ To SQL中如何使用IN,

倒让我发现到我一直都未提到这个用法,^_^|||


   有读者来信问及LINQ To SQL中如何使用IN,

 倒让我发现到我一直都未提到这个用法,^_^|||

用法如下:

C#
       var result = from s1 in context.Customers where (new string[]
                      { "UK", "Lisboa" }).Contains(s1.City) select s1;
 
VB.NET
    Dim lists = From s1 In context.Customers Where (New String() {"UK", "Lisboa"}).Contains(s1.City) Select s1
 
那NOT IN呢?
C#
  var result = from s1 in context.Customers where !(new string[] { "UK", "Lisboa" }).Contains(s1.City) select s1;
 
VB.NET
      Dim lists = From s1 In context.Customers Where Not (New String() {"UK", "Lisboa"}).Contains(s1.City) Select s1      

原文:大专栏  LINQ To SQL中如何使用IN


猜你喜欢

转载自www.cnblogs.com/petewell/p/11489862.html
今日推荐