我想使用linq-to-sql在多列中搜索字符串,我想知道如何编写where
子句。我的做法是:我将要搜索的ID列表以及搜索词都传递进去:
public List<long> Seach(string TheSearchTerm, List<long> TheIDs)
{
using (SomeDataContext TheDC = new SomeDataContext())
{
var TheOutput = (from t in TheDC.SomeTable
where TheIDs.Contains(t.ID) &&
where "TheSearchTerm is in one of the columns"
select t.ID).ToList();
}
}
我该如何编写第二个
where
子句以搜索所有列?我考虑了为每列编写一个where子句,但我想知道是否有更好的方法。
谢谢。