日期:2014-05-20 浏览次数:20780 次
public static List<DataRow> FullTextSearch(this DataTable dataTable, string[] keywords)
{
var q = dataTable.AsEnumerable().Where<DataRow>(row => keywords.All(keyword => row.ItemArray.Select(p => p.ToString()).Any<string>(s => s.Contains(keyword))));
return q.ToList();
}
Public Shared Function FullTextSearch(ByVal dat As DataTable, ByVal keywords As String()) As List(Of DataRow)
'Dim q = dat.AsEnumerable().Where(Function(row) keywords.All(Function(keyword) row.ItemArray.Select(Function(p) p.ToString()).Any(Of String)(Function(s) s.Contains(keyword))))
Dim q = From item As DataRow In dat.AsEnumerable Where keywords.All(Function(key) item.ItemArray.Select(Of String)(Function(p) p.ToString()).Any(Function(s) s.Contains(key))) _
Select item
Return q.ToList()
End Function