LINQ : Implementing IN and NOT IN

I got tried of typing

  var result = from s in source
                  where items.Contains(s)
                  select s;

and so I implemented the IN and NOT IN methods as extension methods:

public static IQueryable<T> In<T>(this IQueryable<T> source, 
                            IQueryable<T> checkAgainst)
{
   return from s in source 
            where checkAgainst.Contains(s) 
            select s;
}
 
public static IQueryable<T> NotIn<T>(this IQueryable<T> source, 
                                  IQueryable<T> checkAgainst)
{
   return from s in source 
            where !checkAgainst.Contains(s) 
            select s;
}

Thus, I can now just do the following:

  var result = source.In(items);

What do you think – Good idea, Bad idea, Useless idea?

Twitter Email Linkedin Digg Stumbleupon Subscribe