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

没有更多推荐了,返回首页

私密
私密原因:
请选择设置私密原因
  • 广告
  • 抄袭
  • 版权
  • 政治
  • 色情
  • 无意义
  • 其他
其他原因:
120
出错啦
系统繁忙,请稍后再试