M
Marty M
public abstract class Animal
{
private string Id;
}
public class Dog : Animal
{
//properties/fields for Dog
public void Add()
{logic to persist to database}
}
We'd like Dog to persist himself to database. We'd like classes
derived from Animal to always have a GUID in Id. But derived classes
should not worry about that, they don't have to know about the Id.
How do we do this while making Dog responsible to add himself? We
don't want to use Animal constructor because Id is only used for
Insert. Ideas? thanks! Marty
{
private string Id;
}
public class Dog : Animal
{
//properties/fields for Dog
public void Add()
{logic to persist to database}
}
We'd like Dog to persist himself to database. We'd like classes
derived from Animal to always have a GUID in Id. But derived classes
should not worry about that, they don't have to know about the Id.
How do we do this while making Dog responsible to add himself? We
don't want to use Animal constructor because Id is only used for
Insert. Ideas? thanks! Marty