M
Marty McDonald
public abstract class Animal
{
private Id;
public
}
public class Dog : Animal
{
<<fields/properties for Dog>>
}
When Dog or any other derived class of Animal gets added to the database,
we'd like it to have a unique GUID in Id. This only applies for Insert, not
Select, Delete, Update. Responsibility for database I/O belongs to the
derived classes. But how do we force derived classes to invoke GetGuid? We
want GUID to be generated automatically, developers of derived classes
should not be required to know about this GUID or to generate it. Doing it
in constructor of Animal not preferable because GUID is only required for
Insert. Ideas?
{
private Id;
public
}
public class Dog : Animal
{
<<fields/properties for Dog>>
}
When Dog or any other derived class of Animal gets added to the database,
we'd like it to have a unique GUID in Id. This only applies for Insert, not
Select, Delete, Update. Responsibility for database I/O belongs to the
derived classes. But how do we force derived classes to invoke GetGuid? We
want GUID to be generated automatically, developers of derived classes
should not be required to know about this GUID or to generate it. Doing it
in constructor of Animal not preferable because GUID is only required for
Insert. Ideas?