I have an abstract class named PersonAbstract
. It has an abstract property called Age
abstract public int Age { get; set; }
Two classes called Customer
and Employee
extend PersonAbstract
.
Customer
and Employee
are created using Linq-to-SQL, therefore they have auto-generated code.
The auto-generated code for both of these:
public int Age
{
get
{
return this._age;
}
set
{
this._age = value;
}
}
I add functionality to Employee
and Customer
using a partial class.
public partial class Employee: PersonAbstract
{
.....
How do I change this structure so that the inherited classes (Employee
and Customer
) have their person property overriding the person property in the abstract class without touching the auto-generated code?
Edit:
The issue is that I want to have both classes share some parent class's code. So I have been trying to add the abstract class with the shared code between the interface that implements that has the Age
property and the two child classes. But that code needs access to the Age
property. So the abstract class has to implement the interface using abstract instances of the Age
property and the child classes override that. If this is not possible, how else can I achieve the desired result?
You can't - the autogenerated code isn't using override
, therefore it can't override the existing member.
If you put the age property into an interface though, then the auto-generated code would happily implement the interface for you.