made the query type immutable in nature.

Also changed the sortby method to take a projection instead of a string.