Query builder implementation.