Last post Oct 07, 2010 01:46 PM by haitham khedre
Oct 07, 2010 12:28 PM|dotNet_Student|LINK
I have a table which houses two entities. StaticProgram and
DynamicProgram. There is one column in that table called ProgramType which determines if a program is of Type static or Dynamic. Though these two entities are stored in one table (I am guessing because the primitive fields for Static
and Dynamic programs are exactly the same) but from a business point of view these are two VERY different entities.
So, I created two Classes StaticProgram and DynamicProgram. However, I donot want to create two seperate Data Access Classes because it is going to be the exact same code replicated twice. I tried creating a "Program" class as base class
and inherited StaticProgram and DynamicProgram classes but down casting is not supported so I can't return a "Program" object from the data access class and cast it to "StaticProgram" class.
So, what are my options? Can I create an IProgram interface and have StaticProgram and DynamicProgram implement that interface and have my Data Access class return IProgram? Any other suggestions?
I would appreciate your help!!
interface contract abstract class
Oct 07, 2010 01:46 PM|haitham khedre|LINK