Generalised a method of doing a database query at each parameter point using visitor pattern.