Count() with predicate

Calling Count() with a predicate on a TableQuery causes all rows to be selected then counted.  This fix will correctly generate a WHERE clause.