Linq to SQL - How to compare against a collection in the where clause?
- by Sgraffite
I'd like to compare against an IEnumerable collection in my where clause. Do I need to manually loop through the collection to pull out the column I want to compare against, or is there a generic way to handle this?
I want something like this:
public IEnumerable<Cookie> GetCookiesForUsers(IEnumerable<User> Users)
{
var cookies = from c in db.Cookies
join uc in db.UserCookies on c.CookieID equals uc.CookieID
join u in db.Users on uc.UserID equals u.UserID
where u.UserID.Equals(Users.UserID)
select c;
return cookies.ToList();
}
I'm used to using the lambda Linq to SQL syntax, but I decided to try the SQLesque syntax since I was using joins this time.
What is a good way to do this?