详细了解一个人'亚当' SQL查询
SELECT * FROM tableName WHERE Name = 'Adam'
在Vb中查询Linq
From tableName In something Where row.Field(Of String)("name").Trim = "Adam"
但要了解多个人的细节,亚当'克里斯' SQL查询
SELECT * FROM tableName WHERE Name IN ('Adam', 'Chris')
在VB中查询Linq
编辑: VB中的Linq查询是
来自tableName在某些地方{" Adam"," Chris"}。包含(row.Field(Of String)(" name")。修剪)
答案 0 :(得分:1)
Dim item= From tableName In something
where {"Adam", "Chris" }.Contains(u.something)
select i
试试此代码
答案 1 :(得分:1)
您应该使用Enumerable.Contains
,例如使用您要查找的值数组:
Dim dt = New DataTable()
dt.Columns.Add("ID", GetType(Integer))
dt.Columns.Add("Name", GetType(String))
dt.Rows.Add(1, "John")
dt.Rows.Add(2, "Adam")
dt.Rows.Add(3, "Chris")
Dim values = {"Adam", "Chris"}
Dim results =
From row In dt
Where values.Contains(row.Field(Of String)("Name").Trim)
For Each row In results
Console.WriteLine("{0} - {1}", row.Field(Of Integer)("ID"), row.Field(Of String)("Name"))
Next
输出:
2 - Adam
3 - Chris