Query as case class