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 SQL VB VB.NET .net
想对作者说点什么? 我来说一句

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

关闭
关闭
关闭