1.You could use Entity Framework to manage your entity objects, and all states will be managed automatically;
OR
2.You could add an enum for state then to use it in your class like in the next example:
public enum ObjectStates
{
Unchanged,
New,
Modified,
Deleted
}
public class Student
{
public ObjectStates State
{
get;
private set;
}
public int ID
{ get;
set
{
this.State= ObjectStates.Modified;}
}
public void Delete()
{
this.State = ObjectStates.Deleted;
}
public void Save()
{
this.State = ObjectsStated.Unchanged;
}
public Student()
{
this.State = ObjectStates.New;
}
public Student(...some params)
{
this.State = ObjectStates.Unchanged;
}
}