Move contribution entity query code to own ns.