I have an employee class in my application. The constructor for the class takes an employee ID. The way I try to check if the employee ID is valid is something like this
Employee emp = new Employee("E11234");
if (emp.IsValid())
{
// do whatever is required
}
else
{
// show an error message
}
In the constructor, I try to access the database and if I can retrieve records, I fill the values for the private members, else if no records exist, I set the isValid property to false.
Is this a correct way of achieving what I want to or is there a better method?