Tuesday, November 24, 2009

LINQ Equivalent To A T-SQL IN


SELECT * FROM MemberInfomation WHERE @samAccount IN ('adf','asfd','wqewe')
Similarly you can do a IN like filter in LINQ:

public List GetInformation(String[] samAccounts)
{
SomeDataContextdc = new SomeDataContext();
return dc.MemberInfomation.Where(
o => samAccounts.Contains(o.samaccount)
).ToList();
}
Got help from here.

No comments: