I'm making a simple web form to gather customer data and enter it into a database. I have 5 sub-classes: Customer
, Bank
, Employee
, Owner
, and TradeReference
which inherit from the abstract class, DataEntry
. DataEntry
has a function public void InsertSelfIntoDataBase(int id);
. The id parameter is the primary key from the Customers Table (Bank, Employee, Owner and TradeReference have a many-to-one relationship with Customer), so a Customer
doesn't need an id to be inserted (CustomerID is auto Incremented in the database).
Currently, my code is set up so that Bank
, Employee
, Owner
, and TradeReference
implements the InsertSelfIntoDataBase
function in the parent class, while Customer
throws a NotImplementedException, so the code for the Customer
class code looks a little like this:
public int InsertSelfIntoDataBase()
{
int customerID = InsertCustomerAndReturnScalor();
return customerID;
}
public override void insertSelfIntoDataBase(int id)
{ throw new NotImplementedException("Customer does not use this function"); }
This implementation works, but it bugs me that I have to use a NotImplementedException; Like I can't shake the feeling that my professors form college somehow know and are silently judging me. Is there a better way of doing this?