I have an application with my object types that inherit from a base class that contains the majority of properties for the application objects. All the object types are stored in one table in the database. The "ClassType" column determines what object type I cast the SqlDataReader row to.
Here is my current implementation:
SqlDataReader dr = SqlServerHelper.ExecuteReader("MyStoreProc", MySqlParmas);
if(dr.HasRows)
{
while(dr.Read())
{
switch(dr["ClassType"].ToString())
{
case "ClassA":
//cast sqldatareader a ClassA object
ClassA a = new ClassFactory.CreateClassA(object p1, object p2);
case "ClassB":
//cast sqldatareader a ClassB object
ClassB b = new ClassFactory.CreateClassB(object p1, object p2);
//it continues for all objects with app....
}
}
}
dr.Close()
My question is is their a better implementation for this type of processing?