{
var predicate = PredicateBuilder.False
foreach (string keyword in keywords)
{
string temp = keyword;
predicate = predicate.Or (p => p.Description.Contains (temp));
}
return dataContext.Products.Where (predicate);
}
see C# in a Nutshell
Similarly you can do a IN like filter in LINQ:
SELECT * FROM MemberInfomation WHERE @samAccount IN ('adf','asfd','wqewe')
Got help from here.
public ListGetInformation(String[] samAccounts)
{
SomeDataContextdc = new SomeDataContext();
return dc.MemberInfomation.Where(
o => samAccounts.Contains(o.samaccount)
).ToList();
}
//put this in a static class, singleton, abstract class, or whatever fits your need
private SortedList _CriteriaItem;
//get data from database and iterate over the dataset to populate the list
public void Add(object Key, object Value)
{
_CriteriaItem.Add(Key, Value);
}
public String GetDescriptionByCode(String key)
{
if (_Item.ContainsKey(key))
{
return _Item[key].ToString();
}
return "";
}
public String GetCodeByDescriptionBy(String description)
{
if (_Item.ContainsValue(description))
{
foreach (String key in _Item.Keys)
{
if (_Item[key].ToString() == description)
{
return key.ToString();
}
}
}
return "";
}