I'm hoping someone can help me:
I'm using an interface to access my data, the Find method is:
public IQueryable<T> Find<T>(Expression<Func<T, bool>> expression) where T : class, new()
{
return (IQueryable<T>) _db.GetCollection<T>(typeof(T).Name, WriteConcern.Acknowledged).AsQueryable().Where(expression);
}
I'm trying to build an expression to fetch all ObjectIds within a list of ObjectIds.
something like: r => r.id.ContainsAny(List_Of_IDs); //where List_Of_IDs is of type: List
I also tried: r => r.id.ContainsAny(new[] {id1, id2, id3}) //where id1, id2, id3 are type ObjectId
But I get an error that ContainsAny doesn't support this parameter.
I was hoping to duplicate the functionality of an IN statement in SQL. My goal is that I want the user collection to contain a list of products as a list of ObjectIds and then I want to query the products collection and get all documents in the user's list of Product IDs.
Is this possible? Does anyone know what I'm doing wrong?
Thanks so much for any assistance! Steve
BTW: here is where I send the expression to the repository method:
public static List<product> getByIDlist(List<ObjectId> IDs)
{
return (List<product>)repo.Find<product>(r => r.id.ContainsAny(IDs));
}