I need to convert JSON object to entity, I have many entities and I don't want to write my code some times, so I built an entity-base class and I want to do deserialize to entity (without know which derived-entity call to the base-entity).
Can I do it?
This is my base class (It is abstract class)
public abstract class AbstractEntity
{
EntityState EntityState { get; set; }
DateTime CreatedDate { get; set; }
DateTime? ModifiedDate { get; set; }
string CreatedBy { get; set; }
string ModifiedBy { get; set; }
public EntityState getEntityState()
{
return EntityState;
}
public void SetEntityState(EntityState entityState)
{
EntityState = entityState;
}
}
The first ent:
public class TABLE1: AbstractEntity
{
public TABLE1();
public string ID{ get; set; }
public string ADDRESS{ get; set; }
public virtual ICollection<TABLE2> TABLE2 { get; set; }
}
The second ent:
public class TABLE2: AbstractEntity
{
public TABLE2();
public string ID{ get; set; }
public string ADDRESS{ get; set; }
public virtual TABLE1 TABLE1{ get; set; }
}