I have 3 database tables, all of them have the same 5 columns.
They differ in that table#2 and table#3 each have another ID column in them.
I don’t want to create 3 seperate classes for this, but the problem is in my database helper class I have a method that loads the classes, like:
public static LoadClass1(SqlDataReader reader)
{
Class1 c1 = new Class1();
c1.prop1 = (int)reader["prop1"]
}
I don’t want to have to create 3 seperate load helper methods, and have to copy the code over on all of them. (I don’t mind creating 3, but only having to set the fields that are different in each one).
Four methods: one that loads the core fields, three others that call the core method and load the extra fields. This would work best with a base class with the core properties, and 3 subclasses.