Creating a generic method for fetching resultset