Simply remove the Compile
because that creates a delegate
that the driver can't translate into a mongo query:
public IList<TEntity>SearchFor(Expression<Func<TEntity, bool>> predicate)
{
return collection
.AsQueryable<TEntity>()
.Where(predicate)
.ToList();
}
It does however means that the predicate expression must be translatable by the MongoDB
driver.