Sorry if you saw my previous post - I missed something important in your question.
You can use partial classes. Make your incomplete class an internal field with an instance of the base class that you want, and implement all the methods and properties (if they are not already implemented in essence). If you are trying, then to allow the use of your entity class, you can use public static implicit operatorin your base class (or in the class of partial entities) to allow conversion without hassle.
If you have an abstract base class MyBaseClass, you can do something like:
public partial class MyEntityClass
{
private MyBaseClass _baseClass;
private MyBaseClass BaseClass
{
get
{
if (_baseClass == null)
{
_baseClass = new MyBaseClass();
}
return _baseClass;
}
}
public string BaseClassString
{
get
{
return BaseClass.BaseClassString;
}
set
{
BaseClass.BaseClassString = value;
}
}
public static implicit operator MyBaseClass(MyEntityClass e)
{
return new MyBaseClass() {
Property1 = e.Property1,
Property2 = e.Property2
};
}
public static implicit operator MyEntityClass(MyBaseClass b)
{
return new MyEntityClass() {
Property1 = b.Property1,
Property2 = b.Property2
};
}
}
source
share