score:0

Accepted answer
where !condition || predicate(b)

score:-1

void main()
{
   var list=new int []{1,2,3,4};
   var query=from l in listings.whereif(listhaselements(list),s=>list.contains(s.id))
   select l;
   query.dump();
}
public bool listhaselements<t>(ienumerable<t> it)
{
    return it.any();
}

public static class ext {
    public static iqueryable<tsource> whereif<tsource>(this iqueryable<tsource> source, bool condition,
        expression<func<tsource, bool>> predicate)
    {
        return condition ? source.where(predicate) : source;
    }
}

Related Query

More Query from same tag