I have a class Record
that works fine:
public class Record
{
protected string table;
protected string idcolumn;
public Record(string _t
If you get an InvalidCastException
then theRecord
is not an Order
and you can't cast it. You could only cast it if it were created as an Order
or a subclass of Order
.
My guess is that whatever fetches the data from the database creates a Record
when it could create an Order
(and return it as a Record
). Something like:
public Record Fetch(int id)
{
// ... get data from db
Record rec;
if(data.Type = "Order")
rec = new Order();
else
rec = new Record();
return rec;
}