So what I'm wondering is if it's possible to make a generic Postgresql connection class where you could pass as a parameter the object type you'll want to read from the DB (as a string) and then actually read from DB and return the proper List of objects.
Something like:
class DbConnection{
string type;
public DbConnection(string objectType) {
type = objectType;
}
public getConnection() {..}
public List<Object> readObjectsDb() {
...
return List<type> theObjects // type is the atually class type, no longer the string now
}
}
Basically I'd be able to read from any Postgresql db with this class based on an input parameter, and knowing that the type I'm passing actually exists in my program.
Is it possible? Maybe with reflection somehow?
Aucun commentaire:
Enregistrer un commentaire